Every time I close my terminal and reopen it, simples command(e.g. ls) doesn't work. It shows the following error,

irfan@irfan-Y500-Elementery:~$ ls
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found

I have to execute the following command export PATH=/usr/bin:/bin every time to correct this error,

irfan@irfan-Y500-Elementery:~$ export PATH=/usr/bin:/bin
irfan@irfan-Y500-Elementery:~$ ls
Assets   Documents        Example.java     Music       Public     Videos
Blender  Downloads        export           output.pdf  sudo
Desktop  Elementary Luna  jmonkeyplatform  Pictures    Templates

My questions is, why I have to do it every time? and what do I have to do to solve the repetition.

My /etc/environment files contains the following,


Note : I am using ElementaryOS(based on Ubuntu 12.04)

Edit 1:

echo $PATH returns /usr/local/jre1.7.0_51/bin:

I followed this answer to set java path.

I added

export PATH 

to my /home/irfan/.bashrc file. I guess this caused the problem

  • 2
    If you don't run export PATH..., what is the result when you run echo $PATH? Also, try running echo 'PATH DEFAULT=${PATH}:/usr/bin' >> .pam_environment and rebooting. – Wilf Mar 2 '14 at 20:37
  • @Wilf I tried running echo 'PA.. and rebooting. But, echo $PATH shows only jdk on my path. – Quazi Irfan Mar 2 '14 at 21:14
  • 1
    Close-voters: This question says it's about ElementaryOS rather than Ubuntu so ordinarily it would be closed. But it already has a good answer that doesn't appear Elementary-specific at all and would help Ubuntu users too. In effect I think this question turned out, by the skin of its teeth, to be effectively on topic, and we shouldn't close it. As an separate reason, especially considering the current emphasis on deleting closed questions, this question will likely be deleted if it's closed, which would harm Ubuntu users who'd benefit from the answer. I recommend against closing this. – Eliah Kagan Mar 3 '14 at 2:04

With your problem with the .bashrc file, your method of specifying this only:

export PATH 

likely overwrote the original $PATH - including those already specified. so, to add /usr/local/jre1.7.0_51/bin as a path, in a similar manner to my suggestion above:

echo 'PATH DEFAULT=${PATH}:/usr/local/jre1.7.0_51/bin' >> ~/.pam_environment

This should add it as a path without overwriting the others in $PATH. It should work if you reboot/logout & login/something like that - you will see it in echo $PATH if it works.

  • I removed my jdk edit on PATH variable, and tried your command. But it shows me the following errtor, bash: .pam_environment: Permission denied. – Quazi Irfan Mar 2 '14 at 21:35
  • 1
    Dunno why you need a reboot/whatever, just it does not always pick up the changes. To add something to $PATH, add it to .pam_environment similar to the method described above, or use @Rmano's method. – Wilf Mar 2 '14 at 22:32
  • 1
    See also help.ubuntu.com/community/EnvironmentVariables – Rmano Mar 2 '14 at 22:36
  • 2
    The best place to put environment variables is (at least on ubuntu) on .profile, because the file is sourced by lightdm before starting your session (other distros may differ). You need a login/logout before seeing the changes, a reboot is overkill. .pam_environment may be ok, but is overwritten if you change language configuration/support. And @iamcreasy, if you want to add something to a file, use >> instead of > in the redirection. – Rmano Mar 4 '14 at 4:17
  • 1
    @iancreasy - sorry - one > overwrites, two >> adds to it - added edit. – Wilf Mar 4 '14 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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