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?

1 Answer 1


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.

  • and what do I do?
    – Incerteza
    Jul 14, 2014 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, 2014 at 12:18
  • and how do I remove the one I've already added?
    – Incerteza
    Jul 14, 2014 at 12:58
  • 1
    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, 2014 at 13:10
  • 1
    ...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, 2014 at 14:59

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.