Contact us

Print

Set user

It is not always very convenient having to log out of the system completely in order to log in as another user. This may be because you have certain tasks running and you don’t want to end them. The “su” ( set user) program is used to temporarily become another user. You can “su” from a regular user account to the root account or vice-versa.
It changes the current user to have the access rights of the temporary user.

The HOME, LOGNAME, and USER environment variables will be set to those of the temporary user by default.

To temporarily become another the user “me”

1. While logged in as the root user, switch to the user “me”. Type
root@localhost root# su me

me@localhost root$

The su command did not prompt you for the user me’s password because you are root
2. Change to me’s home directory.
me@localhost root$ cd

me@localhost me$ cd

3. While temporarily logged in as me, use su to login as the user ying. Type:
me@localhost me$ su ying

password:

ying@localhost me$

4. To logout of ying’s account type:
ying@localhost me$ exit

This will throw you back into me’s account.

5. Logout of me’s account to get back to the root account. What is the command?



To make su inherit all environmental variables of the new user

1. To force “su” to use all the environmental variables of the temporary user. Type:
root@system1 root# su – me

me@system1 me$

The difference is immediately obvious. Notice the current working directory.

2. Logout of the system completely and reboot the machine.


Created by: system. Last Modification: Tuesday 25 of November, 2008 16:46:02 EST by admin.

...