## 49.9. Substitute Identity with su

You don't have to login as a specific user -- you can login as yourself and then issue a su command to login as another person.

Invoke su with a username and you'll be prompted for that person's password. If you invoke su without a username, the system logs you in as root and asks you for root's password. Without passing in any other flags, you'll be logged in with your environment variables, except for HOME, SHELL, and USER. If you want to emulate the full environment of the user -- for debugging purposes or whatever -- use the -l flag with su:

>     bash-2.04$ su -l
>     Password:

Using su to emulate another person's account is an effective debugging solution if you're trying to determine why a person is having problems accessing an application. In addition, it's also an effective way of logging into root without logging in from a console or remotely from another machine or terminal.

You exit the su shell by typing exit or hitting CTRL-d.

SP, JP

Copyright © 2003 O'Reilly & Associates. All rights reserved.