Linux Commands - Shells

Path and Environmental Settings
Users all inherit environmental settings that influence the Path of certain commands.   The root user inherits a different environment than a normal user.  There is a variable that is placed in each user environment that determines commands that they can run without typing the absolute path.  This makes it easier for users to employ commands in their work.  For example if a user would like to use the command “ls” to list the contents of a directory they can simply type the command ls and see the results.  They do not have to type /bin/ls.  That is because the variable for PATH has been set to include /bin in the environment of the user.  If a user types the command “echo $PATH” they will see a list of directories that have been added to the PATH variable so any commands in these directories can be typed without using the absolute path.  Because the command ls is in the /bin directory and that directory is included in the Path of the user the user does not have to type the location of the command, only the command itself.  You can see these Path folders listed separated by a “:”.

Lesson 11 / Lesson 13

mike@ub:~$ echo $PATH

However, the PATH of users is based on the privileges that they have received.  In the example above, mike is the first user created on the Ubuntu system so he will inherit more options with the PATH variable than a normal more unprivileged user like diane that you see listed here.

diane@ub:~$ echo $PATH

The notable differences are the lack of /usr/local/sbin/, /usr/sbin and /sbin all of which aid in the user when they sudo to root to run those commands.
There is even another level access for the PATH variable as it will be different for the root user as well.  You will see that the root user does not have the directory /usr/games which is removed for security reasons.

root@ub:~# echo $PATH

The significance of this information for users is twofold.  One, Linux tries to make it easier to use commands by not having to type the path to the command but being able to run the command by itself, speeding up the process.  Secondly, users need to recognize that if they do not have a command directory in their PATH variable they will not be able to use the command without typing the full path and in the examples above, if they are not a privileged user they cannot use the commands anyway.  Diane in the example above cannot use any commands that are in the /sbin directory as they are reserved for privileged users.


Copyright CyberMontana Inc. and
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874