8.3 Identifying Users
8.3.2 Switching to another user account
You can temporarily switch to another user account to access files and directories that belong to that user by using the su (switch user) command. You sometimes may need to switch to another user account in order to modify files they own or do something on their behalf. Administrators typically utilize the su command when troubleshooting user problems or to test authorization and account behavior with certain applications. When switched to another user's account, you will have access to all of the same files that they have.

To switch user IDs, you must supply the password of the user ID you are switching to unless you are currently logged in as root. When you switch to another user account, you become that user and have all access and privileges that they have. To switch back to your previous user ID, type exit.

The Figure shows two examples of the su command. In the first example, su is used without options. When su is used without options, you will not change directory locations. Environmental settings customized for your user ID will also remain in effect. To switch to another UID and have the system read the new user's initialization files, you must use a dash (-) between the command and the new user ID as shown in the second example.

If su is used without specifying options or a user account to switch to, you will switch to the superuser or root account. System administrators normally work under their regular user account and su to root when necessary to perform administrative tasks. As with switching to another user account, the root account requires knowledge of the root password before the system will allow you to switch accounts.

Command Format:
su [-] username