LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Log Out root Then Log In As Other User (http://www.linuxquestions.org/questions/linux-general-1/log-out-root-then-log-in-as-other-user-238792/)

xtremcoder 10-04-2004 06:33 PM

Log Out root Then Log In As Other User
 
How do I do this? :confused:

btmiller 10-04-2004 06:38 PM

From the GUI or the command line? On the command line, logout, exit, or CTRL+D will work. In the GUI, logout is an option under a menu somewhere, generally. After you have logged out, the login prompt will return and you can login as another user Note: root can open sessions for any other user without specifying a password. In a terminal, as root, type su <user>, and you will become that user. This is handy if you're working as root (which you shouldn't be doing too much) and you need to quickly become another user. Normal users can do this trick, too, but they have to know the password of the user they're su'ing to.

Bruce Hill 10-04-2004 06:41 PM

The command "su" means switch user. The normal user will
have a $ prompt, while root will have a # prompt. If you
only have 2 users and are logged in as a normal user, when
you issue "su" you'll simply be asked for the other user (root)
password like this
Code:

mingdao@james:~$ su
Password:
root@james:/home/mingdao# exit
exit
mingdao@james:~$ su

To logout as root simply issue "exit"

xtremcoder 10-04-2004 06:49 PM

I'm doing this remotely through SSH, so if I type exit it will close my client. :(

I tried logout but it said I had to use exit, and that closes my client. :confused:

Bruce Hill 10-05-2004 12:01 AM

Quote:

Originally posted by xtremcoder
I'm doing this remotely through SSH, so if I type exit it will close my client. :(

I tried logout but it said I had to use exit, and that closes my client. :confused:

My example below might be confusing, but look. That comp has 2 normal users (mingdao and james)
and of course root.

If you issue these three commands on your system ->

man ssh
man exit
(terminate the current process)
man su
(su is used to become another user during a login session. Invoked without a username, su defaults to becoming the super user.)

they may clarify what I might have confused for you.

Code:

mingdao@james:~$ ssh 192.168.1.11
mingdao@192.168.1.11's password:  <- mingdao logged in
Last login: Tue Oct  5 11:41:14 2004 from 192.168.1.31
Linux 2.4.26.
mingdao@paul:~$ su  <- su is switch user
Password:  <- I entered the password for root, so it su'ed to root
root@paul:/home/mingdao# exit
exit  <- it exited to the user who logged in, mingdao
mingdao@paul:~$ su james  <- switched users to james
Password:
james@paul:/home/mingdao$ exit
exit  <- exited james to mingdao, who started the ssh session
mingdao@paul:~$ su root
Password:  <- su (switch user) to root
root@paul:/home/mingdao# exit
exit  <- exit from root to mingdao
mingdao@paul:~$ su root
Password:
root@paul:/home/mingdao# su james  <- switched users to james
james@paul:/home/mingdao$ su mingdao
Password:  <- switched users to mingdao by entering his password
mingdao@paul:~$ exit
exit  <- exited james (where root su'ed to) to mingdao
james@paul:/home/mingdao$ exit
exit  <- exited mingdao to root, who logged in last
root@paul:/home/mingdao# exit
exit  <- exited root to mingdao, who originally started the ssh session
mingdao@paul:~$ exit  <- exited the ssh session, because mingdao started it
logout
Connection to 192.168.1.11 closed.
mingdao@james:~$



All times are GMT -5. The time now is 04:42 PM.