Linux Know-How provides a collection of introductory texts on often needed Linux skills. |
Home Newbie Guide Basic Operations Basics Changing the PATH | ||
See also: Permissions for directories | ||
Search the VIAS Library | Index | ||
Changing the PATH
The PATH is the list of directories which are searched when you request the execution of a program. You can check your PATH using this command: echo $PATH which, on my system , shows the PATH for the user "yogin" to be: /opt/kde/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/yogin/bin The ":" is a separator, therefore the above PATH represents a list of directories as follows: /opt/kde/bin /usr/local/bin /bin /usr/bin /usr/X11R6/bin /home/yogin/bin Here is the output from the command "echo $PATH" run on my system on the account "root": /opt/kde/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin You can change the PATH for all users on the system by editing the file /etc/profile and adjusting (as root) the line starting with "PATH=". I do it using the pico editor (as root): pico -w /etc/profile (The option -w turns off the wrap of long lines.) Re-login for the change to take effect. To set up the PATH for an individual user only, edit the file /home/user_login_name/.bash_profile (please note the dot in front of the filename--files starting with a dot are normally invisible, you have to use ls -a to see them). If you really want to have the current directory on your PATH, add "." (dot) to your PATH. When used in the place when directory name is expected, a dot means "the current directory". The specification for the path in /etc/.bash_profile may then look like this: PATH="$PATH:$HOME/bin:"." export PATH This command takes the contents of the environmental variable called PATH (as set for all users in /etc/profile), and appends to it the name of your home directory as set by the variable HOME with an attached "/bin" and then a dot. Finally, the command assigns the resulting string back to the variable called PATH. It is necessary to use the command "export" after modifying PATH or any other user-environment variable, so that the variable is visible outside of the script that sets it.
|
||
Home Newbie Guide Basic Operations Basics Changing the PATH |