Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 am doing this:

$ which cabal
$ export PATH=$PATH:$HOME/.cabal/bin
$ which cabal

I expect to get /.cabal/bin/cabal for $ which cabal (this path exists) after this. But I don't even after re-opening the terminal. How come?

share|improve this question
up vote 7 down vote accepted

The paths in $PATH are searched in order. This allows you to override a system default with:

export PATH=$HOME/bin:$PATH

$HOME/bin is now the first (highest priority) path. You did it the other way around, making it the last (lowest priority) path. When the shell goes looking, it uses the first match it finds.

In case it's not clear, this all works by concatenating strings. An analogy:


$WORD is now foobar. The : used with $PATH is literal, which you can see with echo $PATH.

share|improve this answer
and what do I do? – アレックス Jul 14 '14 at 12:05
Use export PATH=$HOME/.cabal/bin:$PATH -- with $PATH after $HOME/.cabal/bin. In case it's not clear, this works by concatenating the old value of $PATH with some new value(s). Analogy: WORD=bar; WORD=foo$WORD -> $WORD is now foobar. WRT $PATH, don't forget the colon in between. – goldilocks Jul 14 '14 at 12:18
and how do I remove the one I've already added? – アレックス Jul 14 '14 at 12:58
If you did it on the command line, you can just exit the shell/terminal you're using -- export applies it to the current shell and all its children, not everything that's running. If you put it in .bash_profile or something, just change it and log in again. In any case, it's harmless to add the path at the beginning and leave it at the end as well. – goldilocks Jul 14 '14 at 13:10
...the issue is that some graphical login systems ("display managers") don't source .bash_profile, but they do use .xsession -- so if you source ~/.bash_profile in ~/.xsession it will work. unix.stackexchange.com/questions/47359/what-is-xsession-for – goldilocks Jul 14 '14 at 14:59

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.