1~ $ echo $PATH
2/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/aamnah/Dropbox/todo
3
4~ $ cat /etc/paths
5/usr/local/bin
6/usr/bin
7/bin
8/usr/sbin
9/sbin
10
11PATH=/usr/local/bin:$PATH # prepend a path to your current $PATH
The following command adds (appends) a path to your current path:
1export PATH=$PATH:/my/custom/path
If you want your setup to execute this command every time, there are a number of places where you can put it. When you login, the following scripts will be executed in this order:
1/etc/profile (which starts by loading everything in /etc/profile.d)
2~/.profile (which starts by loading ~/.bashrc if you are running bash)
To overwrite an existing PATH, use the same export command without the $PATH included in the value. Like so:
1export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
:
is the seperator between different PATH locations.
To find out if a command is in the path, use which
. For example:
1which node
on a Mac will give you
/usr/local/bin/node
If you get nothing from the which node coomand, node’s not in the path.
~/.profile is only loaded if ~/.bash_profile or ~/.bash_login DO NOT EXIST. Otherwise, at least bash, will load them instead. It is suggest to use .profile and not the bash specific scripts. So, if in these attempts you created .bash_login, please delete it now.
~/.bashrc is only loaded if you are running an interactive session. (something with a prompt where you can actually type something.
~/.bashrc is loaded again and again, everytime you open up a new terminal. So a new tab in gnome-terminal, a new virtual terminal, etc. So even if you don’t login again, .bashrc is loaded (and thereby resets its environment) everytime you open a new shell.
Something like byobu should really go into .profile, (otherwise it won’t work ;-)
Something like paths should go into .profile if you want it to work outside of the interactive sessions. (say when you press alt+f2 in gnome)
Check what current $PATH is:
1echo $PATH
OR
1printf "%s\n" $PATH
You can add path to any one of the following method:
$HOME/.bash_profile
file using export syntax. e.g. export PATH=$PATH:/new/dir/location1
/etc/paths.d
directory.