Next Previous Contents

7. Changing user ID

7.1 su

Command su sets a new user id to use. If no user id is given, root is used.

Normally su invokes a subshell with a different user id. With argument '-' (more recent synonyms -l or --login) su invokes shell like login shell. However, it does not use login program to do this but uses a yet another built-in path for login 'simulation' (term used in the source code). It is:

for normal users

/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:. 
for root user
/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin

su makes many quite subtle environment changes as well.

7.2 sudo

There is a group of commands that make use of super user commands safer. They allow better logging, user-based restrictions and usage of individual passwords. Most widely used is sudo.

$ sudo env

executes command env as super user (if it is configured to allow it).

sudo command has again a different approach to path handling. It modifies the search path so that the current directory is always the last one. However, it does not modify PATH environment variable. 'sudo env' and 'env' give the same value for PATH variable. Sudo adds just couple of environment variables like SUDO_USER.


Next Previous Contents

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:58:11