shellspells beta


sudo -h | -K | -k | -L | -V
sudo -v [-AknS] [-p prompt]
sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U username] [-u username|#uid] [command]
sudo [-AbEHnPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u username|#uid] [VAR=value] [-i | -s] [command]

sudo allows a permitted user to execute a command as the superuser or another user.

This command replaces the superuser entirely on Debian/Ubuntu systems. This may take a bit of getting used to, but soon becomes second nature. Once the password has been entered, it is remembered for 15 minutes. This makes sudo quite convenient to use.


Install a package as the superuser

$ sudo apt-get install ssh

Run a command as a different user

$ sudo -u mythtv mythfrontend

Simulate a root login. Using -i places you into an interractive session with superuser permissions.

$ sudo -i
# echo deb maverick main >> /etc/apt/sources.list

gksu pops up a graphical dialogue requesting the sudo password

$ gksu gedit /etc/hosts

Redirection is tricky using sudo

The following does not work:

$ sudo echo deb maverick main >> /etc/apt/sources.list
-bash: /etc/apt/sources.list: Permission denied

You must use 'sudo su -c' to run the command. Note the quotes around the full command:

$ sudo su -c 'echo deb maverick main >> /etc/apt/sources.list'