if I type
echo $PATH
I only get
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
how can I add /usr/local/sbin to the path, so it is already there the next time?
(I use debian squeeze)
if I type
echo $PATH
I only get
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
how can I add /usr/local/sbin to the path, so it is already there the next time?
(I use debian squeeze)
The easiest way is to add this line to your user's ~/.bashrc file:
export PATH=$PATH:/usr/local/sbin
Bear in mind that /sbin/, /usr/sbin and /usr/local/sbin are not in normal users' $PATHs by default because these directories tend to contain "dangerous" executables. Things like fdisk or deluser that need administrative privileges and can harm your computer. They should be in root's path by default and you need to be root to run them anyway, so it migh be a good idea not to add them to a normal user's $PATH.
.bashrc is only called once at the start of the session. Your own scripts, you could store them in ~/bin, and add that to the path, for example.
– slhck
May 15 '13 at 12:19
PATH=$PATH:/foo appends /foo to the current value of $PATH. PATH=/foo:$PATH prepends /foo to the current value of $PATH. As for where you place your own scripts, the most common is ~/bin but you can use whatever you like as long as you add it to your $PATH as described. Personally I use ~/scripts.
– terdon
May 15 '13 at 12:20
/usr/local/bin as /usr/bin is generally used by the 'OS vendor'. This means that if you do updates, and your script happens to have a name of some new inclusion, it will be over-written.
– vgoff
May 15 '13 at 12:28
foo, the one that was found first, so the one in the directory of your PATH that comes first, will be executed when you run foo. So it's up to you. If you want the new dir to take precedence, add it to the beginning, otherwise, add it to the end.
– terdon
Aug 31 '16 at 10:44
brew on a mac. Other examples can come from version conflicts in standard tools.
– drevicko
Sep 01 '16 at 09:29
Add the following to the end of the .bashrc of the user:
export PATH=/usr/local/sbin:$PATH