Using "su" to become root

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

Using "su" to become root

Postby almigi » Thu May 14, 2009 17:26

Hello everyone, I have a question regarding doing things as root. Prior to using Sabayon, I used Ubuntu and a few Ubuntu based distros (Mint and CrunchBang), so, I'm used to the "sudo" method of doing things.

Let's say for example, I am installing a program, and I want to do it from the Terminal because I'm old fashioned that way :)

I enter the terminal and I type "su" and then my root password when prompted. I type the necessary commands to install the program using the package manager, and when I'm done, do I simply close the Konsole window or do I have "su alan" (alan is the username of my regular account on my machine) to log back into my regular user account?

If I want to stay in the Konsole and do more command line work (that doesn't require root access) would I "su alan" then? Or, is there a better way to return to normal after switching over to root?

Thanks.
almigi
Baby Hen
 
Posts: 13
Joined: Wed May 13, 2009 17:48
Location: Fairview Park, Ohio, USA

Re: Using "su" to become root

Postby kodiakmax » Thu May 14, 2009 17:55

This may be more info than you are asking However, I will attempt to explain it,
You can just close the terminal to continue going about your day with the gui no problem. If you want to keep that window open and switch to your regular user account you can do it 2 different ways. either you can type "exit" or you can type "su alan" if you type "su alan" it will still have the "su" access open underneeth the new "su alan". So, to clear out the privileged terminal you would have to execute "exit" twice or close the terminal.

FYI: Contrary to popular belief "su" does not mean super user. "su" means switch user. it just defaults to root access without a user specified.

Example:
open terminal
$ -- first user level
su
# -- first root level
su alan
$ -- second user level
su
# -- second root level
su alan
$ -- third user level
exit
# -- second root level
exit
$ -- second user level
etc, etc, etc.

or just close out that terminal window. this becomes more important if you doing it in a tty ( if you using a ctl+alt+F1) screen. Because if your doing it in a tty and forget which level you are on it leaves your computer open to whoever whats to use it. So, IMO if you want to switch back to regular user you should always use the command "exit" and never build up different levels.

If you want to know more about su:
type the command
Code: Select all
info su


also
wikipedia (though not as much info) -- http://en.wikipedia.org/wiki/Su_(Unix)
If you check the wiki, use the search function and google you can find the answer to most of your questions.

Remember to mark your thread [Solved] if your issue is fixed.
User avatar
kodiakmax
Advanced Hen
 
Posts: 278
Joined: Thu Oct 16, 2008 23:46

Re: Using "su" to become root

Postby Thev00d00 » Thu May 14, 2009 18:22

Code: Select all
su # become root
exit # leave


Code: Select all
su # become root
Cntl + D to leave


its nested so this is shown with indentation to make it clearer
Code: Select all
su # become root
.    su user # become user
.    exit # go back to root
exit  # leave
Image
Please report Bugs on the Bugzilla, not forum
Please Adopt an Unanswered thread
Website / Blog : v00d00.net
twitter: Follow Me
G+: Circle Me
User avatar
Thev00d00
Generally Awesome (tm)
 
Posts: 1467
Joined: Wed Feb 21, 2007 15:52
Location: United Kingdom

Re: Using "su" to become root

Postby tomv » Tue May 26, 2009 8:51

The above posts were a little round-about. The short of it is, the "su" command starts a new shell as the requested user (in this case root). If you type "exit" or hit "CTRL-D" (end of file), these commands exits the new shell and return you to the old one which is presumably running as a normal user.
tomv
Baby Hen
 
Posts: 11
Joined: Sat Jun 09, 2007 9:47


Return to Beginners|Newbies Area

Who is online

Users browsing this forum: No registered users and 1 guest