Sometimes you may need to add a directory to the Linux PATH, and the reason to do this, could be to have some scripts you may have written included in the execution PATH.
This is done easily by with a single command line, but that is going to last only until you reboot the machine or, if logout and loggin again, so If you want to make it permanent, you may need to edit some config files, there is one global, and there are also specific ones for each user, you may choose which according to your needs. Add a directory to the PATH only for this session
To do this, just run this command from the shell.
Add a directory to the PATH of your user only
Just add one of the above commands to the
.bash_profile file, if you are using bash, you will have to choose the appropriate one if you are using another shell, you may also add these two lines instead of the above one
PATH=$PATH:/new/directory export PATH
Add a directory to the PATH globally
To do this, you will have to edit the
/etc/profile file, (you will have to be root to do that), and find this line.
And add your directory there.
When you are running script files, the PATH issue can give some headaches, remember that shell scripts uses its own Environment variables, so add the directory to want in the PATH in the shell script itself, as one of its lines, if you are having problems, I have written an small post about it some time ago, read it here