What it is?

If you have been using Linux for awhile you might have a number of scripts that you like to use to perform various tasks. You are probably sick of navigating to your scripts directory and typing "./script_name". Fortunately we can make it so that we run them just like an installed program.

When your run a command the computer begins looking for a matching command. It looks in one folder, if its not found it looks in the next folder, and that continues until the command is found or not found. This is called the Path.

To see your path open a terminal and type:
echo $PATH.

This is my path:

/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/kde/bin:/usr/bin/vendor_perl: /usr/bin/core_perl:/home/bdvTek/scripts:/home/bdvTek/scripts/archbox

Notice the bold, when I execute a command it will also search in these two directories that I have specified. If I put a script in either of those two folders I can execute it without the need to start with "./".

Now I could just place my scripts into any of the other folders, say, /usr/local/sbin and it would work, but for the sake of organization I want to have my scripts in a different location.

How to configure it

So how do you do this? Well there's two things to mention. You can temporarily set the path by entering the command:

This will remain in effect only for the current terminal you have open. In order for this to be a persistent setting you will need to edit one or two configuration files.

First open the file .bashrc, found in your home directory, using your favorite text editor. Add a line to this:
export PATH=$PATH:/path/to/your/directory:/path/to/another/dir

This will append a path onto your current path. Notice the ":", this is very important, this is what tells the system to append the path rather than replace it. It is also important that you do not put a ":" at the end of your path.

Depending on your distribution you may also want to edit the file /root/.bashrc and add the same thing so that you have the same setting while you are using the super user account. Remember this isn't going go take effect until you open a new terminal.