linux poison RSS
linux poison Email

How To Set $PATH Variable in Linux

When you type a command at the shell prompt, it has to be read off disk out of one or other directory. On Linux all such executable commands are located in one of the directories. A file is located in the directory tree according to its type, and not according to what software package it belongs to. Hence, for example, a word processor may have its actual executable stored in a directory with all other executables, while its font files are stored in a director with other fonts from all other packages.

The shell has a procedure for searching for executable when you type them in. If you type in a command with slashes, like /bin/cp then it tries to run the named program: cp out of the /bin directory. If you just type cp on its own, then it tries to find the cp command in each of the sub-directories of your PATH. To see what your PATH is, just type

echo $PATH

You will see a colon separated list of directories. Note that the current directory . is not listed. It is very important that the current directory not be listed for security reasons. To execute a command in the current directory, we hence always type ./.

To append for example a new directory /opt/gnome/bin to your PATH, do

export PATH

you can also do this in one line: export PATH="$PATH:/opt/gnome/bin"


Post a Comment

Related Posts with Thumbnails