Linux System Administration
Shells
The Command Path
How can we change the PATH ?
In a shell, type the following:
[guest@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/guest/bin
[guest@localhost ~]$ PATH=/sbin:$PATH
[guest@localhost ~]$ echo $PATH
/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/guest/bin
This changes the PATH for this shell. If you open a new shell, then PATH will be the default.
Note that the shell looks for a command from left to right along the PATH.
The command above will look in /sbin first. If you want to look in /sbin last, do the following:
[guest@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/guest/bin
[guest@localhost ~]$ PATH=$PATH:/sbin
[guest@localhost ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/guest/bin:/sbin
Prev
Page 7
Next