Monday, April 20, 2015

Adding folder to PATH in Ubuntu Linux

To add folder to the PATH for the current terminal session write:
export PATH=$PATH:path/to/folder
However, you need export if PATH is not in the environment and it usually is. So write only:
PATH=$PATH:path/to/folder
or
PATH=path/to/folder:$PATH

First example is specifying the folder to be read at the end (after all other folders in PATH) and the other one is specifying the folder to be read first. Sometimes if you have an older version of the binary in one folder that is already in PATH and you specify folder with the new version to be read at the end, the older version will be read first and you wont be using the new version of binary. In this case specify folder to be read first (example2).
To make changes permanent edit ~/.bashrc file and place the line above in it.
~/.bashrc gets sourced every time you open a terminal.

No comments:

Post a Comment