Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following /etc/environment:

export PATH=$PATH

Whenever I log in I get the following errors:

-bash: id: command not found
-bash: tty: command not found

What am I doing wrong?

(my actual /etc/enviroment is more complicated and sets up java onto the path but for simplicity I cant even get the above to work)

I'm using Centos6

share|improve this question
what makes you think the two are related? – stew May 16 '12 at 11:41
Please could you add more detail. What makes you believe that $PATH had anything useful in before you assigned it to $PATH and exported it? – Sirch May 16 '12 at 11:41
@stew because I dont get that error without that line. – DD. May 16 '12 at 14:17
up vote 1 down vote accepted

I think the cleaner approach is to use an entry in /etc/profile.d over /etc/environment, but can you echo the output of $PATH? That may be the real issue. Or at least show the complicated environment file's details.

share|improve this answer
Apparently /etc/environment is for system wide… – DD. May 16 '12 at 14:21
@DD. While that may be the case, CentOS/RHEL may be using it differently. /etc/environment is rather integral to my Ubuntu boxes, but it's an empty file in my stock CentOS units. – Magellan May 16 '12 at 16:02

You've misunderstood the /etc/environment syntax. This is not a shell file (.sh file). The /etc/environment is loaded when the shell doesn't exist, even before it is decided whether it would be sh or csh or no shell at all, but some other process. So it has a really basic syntax.

As seen on this Unix/Linux StackExchange answer:

you can only put static environment variable definitions, of the form VARIABLE=VALUE or VARIABLE="VALUE", with one definition per line. You can't have arbitrary shell commands, you can't refer to the value of another variable by writing FOO=hello+$BAR

In your case, you also shouldn't put export, this is a shell command too.

share|improve this answer

This sounds like a quoting problem (i.e. the current value of $PATH contains IFS characters and bash is trying to execute some part of it). Variable values should almost always be quoted, so that line should look like:

export PATH="$PATH"

However, since you're not changing the value of $PATH you don't actually need the assignment, and the following is sufficient:

export PATH
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.