Tips Linux Explorers   All Things Linux Forum   Great Linux Links   Hometown   Email 


As you type a command in a console you do not have to know the full PATH to that command or program, just the name will do. Type ¨kmail¨ and it will bring up the Kmail program, type ¨cp fileX /mnt/win_c¨ and it will call on the ¨cp¨ executable to copy ¨fileX to the Windows C: partition. No need to type the full path to those executables.

This is because the Kmail and the cp executables are ¨in your PATH¨ ( the full paths are /usr/bin/kmail and /bin/cp )
Most of these executables for normal users are stored in /bin, /usr/bin and /usr/local/bin, thus these directories are ¨in your PATH¨

Sometimes however programs are stored in unusual places, or you make your own scripts and programs and store them in a special directory. Then we can add those directories to ¨your PATH¨, so that a simple short command can call them.

First let´s have a look what´s in your path:

$ echo $PATH

You will see something like:


What this means is /usr/X11R6/bin and /usr/local/bin/ and /bin etc. are in your PATH

For root:

$ su
< password >
# echo $PATH

Will give this line:


You notice that the PATHs are different for root than for the normal user ! ( ¨sbin¨ is a good give-away that they are for root )

Now let´s assume you want to add the /home/bruno/progs/exec directory ( where you store your own executables ) to your PATH:

# export PATH=$PATH:/home/bruno/progs/exec

Now you can just type ¨back¨ at the prompt to call on your self-written backup-script or program that you have in /home/bruno/progs/exec.

To permanently add something to the PATH you will have to edit a file, could be in a few different ones ( depending on shell and distro): ~/.profile or ~/.bash_profile or /etc/profile or /etc/csh.login. ( More in-depth and accurate info can be found Here )

There is a line like:


Just add a colon and the new directory, like this:


And save the file. To load the new settings either reboot or:

# source /etc/skel/.bash_profile

Now you know next time you see the error message that something is not ¨in your PATH¨ how to solve this little problem.

UPDATE: Another way to add permanently to the PATH is:

$ export PATH=$PATH:/home/bruno/progs/exec


-- Jul 7 2003 ( Revised Jun 5 2006 ) --

Tips Linux Explorers   All Things Linux Forum   Great Linux Links   Hometown   Email