PATH in Shell script

$echo $PATH

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



The term “bin” for directories that hold executables is short for binary. However, you can also think of it as having the corresponding English meaning—a place to hold things; in this case, executable programs.


When you write your own scripts, it would be nice to have your own bin in which to place them, and have the shell find them automatically. This is easy to do. Just cre- ate your own bin directory and add it to the list in $PATH:


$ cd
$ mkdir bin
$ mv nusers bin
$ PATH=$PATH:$HOME/bin $ nusers


Explanation :

Change to home directory
Make a personal “bin” directory Put our script there
Append our bin directory to PATH Test it out


To make the change permanent, add your bin directory to $PATH in your .profile
file, which is read every time you log in, by putting a line like this at the end of it:
PATH=$PATH:$HOME/bin

Comments