All About $PATH

When issuing commands from a shell, the system will check for programs in the directories listed in your $PATH variable. Multiple paths are the norm, and each should be divided with a colon. Earlier directories will be searched before whatever follows. Here’s an example $PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

To see what’s currently in your $PATH variable

echo $PATH

Adding to Path

Add ~/opt/bin at the end (to be searched after all other directories)

PATH=$PATH:~/opt/bin

Add ~/opt/bin to the beginning (to be searched before all other directories)

PATH=~/opt/bin:$PATH
Snippets and tagged