Thursday, December 3, 2009

How to add a path in linux/unix

Although simple, most of us were sometimes confused about the method to append a path to $PATh variable in Linux/Unix.

Ofcourse, the method differs with different type of shells. Here is list a methods for different shells

Eg : shell prompt> echo $PATH ----> Gives existing search path list
/usr/bin:/usr/lib/:/usr/sbin

Let us assume you want to add /usr/site/bin (Path to be added) to the search path.

1) Bash shells :

bash shell prompt> export PATH=$PATH:Path to be added
bash shell prompt> export PATH=$PATH:/usr/site/bin

2) C Shell :

C shell prompt> setenv PATH Existing list of paths:Path to be added
C shell prompt> setenv /usr/bin:/usr/lib/:/usr/sbin:/usr/site/bin

No comments:

Post a Comment