How to set the $PATH variable in Redhat 9.0
The $PATH variable is a list of which directories Redhat will look in for executable files.
To see what the current path is, type...
echo $PATH
You should get something like the following...
/usr/local/bin:/bin:/usr/bin:/home/myname/bin
This means that when you try to run a program or script (eg: ping, ftp or vi etc), Redhat will look in /usr/local/bin then /bin, /usr/bin and finally in /home/myname/bin to find it.
You can change the path to suit your needs.
EXAMPLE:
To add /sbin to the path, type
export PATH=$PATH:/sbin
To see the result, type...
echo $PATH
/usr/local/bin:/bin:/usr/bin:/home/myname/bin:/sbin
You will see that /sbin has been added.
However, using this method will only modify the path for the current session. Once you log out, anything you've added to the path will be removed, so next time you log in it would have to be added again.
The way to modify the path variable permanently is to edit the bash_profile file (assuming you are using the default bash shell).
To edit the bash_profile, change to your home directory (ie: /home/myname) and type....
vi .bash_profile (note the fullstop before 'bash'. This '.' makes it a hidden file)
then arrow down until you find the line that looks similar to this.....
PATH=$PATH:$HOME/bin
type i to enter 'insert' mode,
then add whatever directory you want to the end of it (remember to use the ':' between directory names).
Press the escape key to exit 'insert' mode,
type :w to write the file
type :q to quit the vi editor