Friday, January 22, 2010

RootSudo still gets me sometimes

From the Ubuntu documentation:

"By default, the root account password is locked in Ubuntu. This means that you cannot login as root directly or use the su command to become the root user."


Still, I find myself in Ubuntu, or today, in Mint, doing one of these numbers:

steve[~]$ su
Password:
su: Authentication failure
steve[~]$


Ugh.

But there are a few ways to get a root prompt in Mint and Ubuntu (be sure that you know what you're doing before you try running any of these commands!!!):

steve[~]$ sudo su
steve-desktop steve # exit
exit

steve[~]$
sudo su -
steve-desktop ~ # exit
logout

steve[~]$
sudo -s
root[~]$ exit
exit

steve[~]$
sudo -i
steve-desktop ~ # exit
logout

steve[~]$



I've seen questions posted about this stuff where someone would simply reply, "read man sudo and man su." But have fun with the section of man sudo that explains the -i option:

-i

The -i (simulate initial login) option runs the shell specified in
the passwd(5) entry of the user that the command is being run as.
The command name argument given to the shell begins with a ‘-’ to
tell the shell to run as a login shell. sudo attempts to change to
that user’s home directory before running the shell. It also ini‐
tializes the environment, leaving TERM unchanged, setting HOME,
SHELL, USER, LOGNAME, and PATH, and unsetting all other environment
variables. Note that because the shell to use is determined before
the sudoers file is parsed, a runas_default setting in sudoers will
specify the user to run the shell as but will not affect which
shell is actually run.

Whoa.

Anyway, for those of you, especially Linux Mint and Ubuntu users, who really want (or need) to understand this stuff, the Ubuntu Community Documentation RootSudo place is a good place to start out:

https://help.ubuntu.com/community/RootSudo#Enabling%20the%20root%20account

No comments: