Add folder to PATH

3

How to add something to PATH ? I have added like

PATH=$PATH:/home/example
export PATH

and it works until I restart , after that when I type env in PATH there is no /home/example.

Saban

Posted 2011-02-27T15:31:09.807

Reputation: 31

Any luck? Just because the files aren' there by default doesn't mean they are't valid. The distribution and version of Linux, and the version of Bash will determine just which file is actually read and used... – peelman – 2011-02-28T19:39:57.670

Answers

3

Add these lines to your ~/.bash_profile or ~/.bashrc.

(Guide which to use)

Daniel Beck

Posted 2011-02-27T15:31:09.807

Reputation: 98 421

2

set it in your ~/.bash_profile or ~/.profile (depending on your bash configuration).

Its just a set of commands that run each time a new bash instance is started. That's always been my hacky way of doing it. It works, so i never sought anything better.

mizar:branches peelman$ cat ~/.bash_profile 
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh

PATH=$PATH:/opt/local/bin/:/usr/local/git/bin/:~/bin/
SVN_EDITOR=/usr/bin/nano
EDITOR=/usr/bin/nano

alias restartgrowl="killall GrowlHelperApp && open -a GrowlHelperApp"
...
mizar:branches peelman$ 

peelman

Posted 2011-02-27T15:31:09.807

Reputation: 4 580

But I don't have any of those files in my home directory . – Saban – 2011-02-27T19:44:57.593

so? create them... – peelman – 2011-02-28T03:06:34.347

2

put it e.g. into .*rc in your home directory so that it runs whenever you run your favourite shell.

examples:

~/.bashrc ~/.bash_profile

for bash

~/.tcshrc

for tcsh

etc etc...

~/.profile usually get loaded every time....

bubu

Posted 2011-02-27T15:31:09.807

Reputation: 9 283