I created the folder $HOME/bin and put some symbolic links in there.

Furthermore I set the checkbox Run command as login shell (according to this question) in the Terminal properties.

Now when I type echo $PATH I see that the bin directory wasn't appended to PATH. I tried to put this (which was default):

if [ -d "$HOME/bin" ] ; then
    export PATH="$HOME/bin:$PATH"

into .bash_profile, .profile and .bashrc but nothing worked.

Do you know what's going wrong here?

Update: If I open a terminal and run . ~/.bashrc the bin directory is appended to PATH correctly. But if I open a terminal and run . ~/.profile it is not appended to PATH (for testing I included the if statment above in both of these files).

Furthermore I added echo "in bashrc" to .bashrc and when I open a terminal it prints "in bashrc", so it doesn't fail at loading bashrc (same test succesfull for .profile).

2 Answers 2


I just found the answer to my problem. The following line was in my .profile:

export PATH="/usr/local/sbin:usr/local/bin:... which of course resets the PATH to this value. That means anything that makes changes to PATH and was above this line just had no effect anymore.

The cause of this problem was the following: Some time ago I modified my .profile with the command echo "export PATH=\"$PATH:$HOME/.npm-packages/bin\"" >> ~/.profile. I thought it would write $PATH as plain text to .profile but instead it resolved it to the actual content of PATH. I had to escape the dollar sign (\$PATH instead of $PATH), now it works like expected.


If it lacks $HOME/bin (or equivalent), the problem is likely in the code you are using to set the PATH. You could check this by commenting out your if/then that sets the PATH and replace it with:

echo "just a test" > ~/justatest
if [ -d "$HOME/bin" ]; then echo "echo bin found" > ~/bin/testresult; fi
chmod 777 ~/bin/testresult

The first line is a sanity check and should never fail. The final lines test the availability of your bin directory. I have used the convention of ~ instead of $PATH -- same thing.

  • I already tried something like this, the code is not the problem. Even if I set the line export PATH="$HOME/bin:$PATH" without the if statement it isn't appended to PATH. And btw I think you mean '~ instead of $HOME', not $PATH
    – SimonH
    Jan 9, 2016 at 9:29
  • Yes, ~ substitutes for $HOME; that's right. If you prepend $HOME/bin to PATH as you indicate, then what does echo $PATH show once you are logged in?
    – Erik Bryer
    Jan 9, 2016 at 17:53
  • It prints all the standard paths like /usr/bin and in addition all the custom paths I added by myself to ~/.profile, like /home/simon/programs/jdk1.8.0_65/bin. Everything's just fine except $HOME/bin. If I open a terminal and run export PATH="$HOME/bin:$PATH" and then echo $PATH the bin directory is appended to PATH succesfully, but only for the current session.
    – SimonH
    Jan 10, 2016 at 15:02

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.