Linux path environment variable
Last Updated on Saturday, 31 July 2010 08:03 Saturday, 31 July 2010 08:01
| Article Index |
|---|
| 1. Using Linux PATH variable |
| 2. Adding a new directory into PATH variable |
1. 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
2. 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















