Using Linux PATH variable

Linux path environmental variable contains a list of directories in which the shell looks for executable programs every time you run a command or program. Use echo command to print your PATH variable:

$ echo $PATH
/home/lilo/bin:/usr/local/bin:/usr/bin:/bin:/usr/games

If the program / command is located within my PATH user do not need to include full path in order to execute a certain command. For example: date command is located within /bin:

$ which date
/bin/date

and /bin is defined in my PATH variable. Therefore, to execute date command is easy as:

$ date

Adding a new directory into PATH variable

From time to time you may need to add new directory into your PATH scope. The following example adds new directory /bin/myscripts into PATH variable:

$ echo $PATH
/home/lilo/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
$ PATH=$PATH:/bin/myscripts
$ export PATH
$ echo $PATH
/home/lilo/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/bin/myscripts
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed on LinuxCareers.com.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: