I am looking to learn sudo commands for the GNOME terminal.

I am an avid user of Ubuntu however I'd like very much to learn as many commands and shortcuts as possible. I am running Ubuntu 12.04 32 bit on a Compaq Presario cq60.

  • 2
    Are you asking about ways to use sudo itself, or are you asking about commands that perform administrative tasks, that must be run with sudo? – Eliah Kagan Oct 3 '12 at 1:29

sudo (superuser do) is a great tool for restricting access to the root account (or other accounts). In normal use, it is setup so that people in the wheel group can run commands as root if they give it their password.

The beauty of sudo is that you can grant root access to certain users without giving them the root password. On top of that, you can specify only to grant them access to certain commands on certain hosts. Best of all, sudo logs every command that is run through it, so you can easily track down any issues that may arise.

Using sudo

Using sudo is ridiculously easy. If you would like to run a command as root, simply type sudo program arguments. For instance:

sudo passwd tstrombe

If you would like to run commands as a user other than root, use sudo -u username program arguments, like so:

sudo -u condor /usr/local/sbin/condor_start

In rare instances, you may need to start an entire shell as another user. This is not recommended because it will not log the commands you execute under this shell, though it sometimes makes things more convenient when you do not have access to a directory you would like to work in. This will start a root shell:

sudo -s 

For more tips, I recommend looking at the sudo manual.

man sudo 

Configuring sudo

Adding yourself to the wheel group

If you type the groups command, you will see a list of groups that you are an active member of.

% groups

wheel uucp dialout audio video condor

If it does not say wheel, you will want to add yourself to the wheel group. You can use the graphical management tools that come with your system, or simply use your favorite text editor as the root user, and edit /etc/group. Add yourself to the line that says wheel:


You will need to logout and log back in for the membership changes to take affect. Before hand, you may want to do the next step, however.

Editing the sudo configuration

Open up a terminal, and make sure the EDITOR variable is set to your preferred editor, otherwise you will be editing the sudoers file using vi.

Now you can launch visudo as root:


Enabling the wheel group in sudo

Put # signs at the beginning of these lines:(if not found)

Defaults targetpw # ask for the password of the target user i.e. root

%users ALL=(ALL) ALL # WARNING! Only use this together with 'Defaults targetpw'!

You will then see two lines that mention the wheel group. If you have no sensitive data on your machine, and absolutely trust that no one but you would ever use it or get into it, you can uncomment the NOPASSWD one, otherwise, I do highly recommend the first option. This shows our recommended configuration:

# Uncomment to allow people in group wheel to run all commands

%wheel ALL=(ALL) ALL

# Same thing without a password


You can now save this file and quit. You should now be allowed to use the sudo command. Changing the password timeout

By default, sudo will ask you for your password after 5 minutes of not using it. You can change this timeout to 20 minutes by adding the following option to your sudoers file with visudo.

timestamp_timeout = 20

If you really want, you can also specify this timeout on a per-user basis.

You can do much more.

  • 1
    Note: This answer is out of date. There is no longer a wheel group and it's strongly suggested to consider adding local content in /etc/sudoers.d/ instead of directly modifying this file. – Elder Geek Mar 1 '17 at 16:39

Probably your concept about sudo is wrong, to know it's function:

Type man sudo in terminal

It is a tool that let a user to do something on behalf of another user.In mostly used to get root privilege for normal users.

Eg. apt-get install need root permissions to install softwares. So we use sudo apt-get install

  • not fully explained the usage of sudo command – Pankaj Gautam Feb 28 '17 at 11:46


  • sudo help you execute a command as another user, Not only root.
  • sudo may need you to input password, this password is the password of current user ,not root.

For example:

You have three user in your linux system, userA, userB, and root. When you logged with userA, suppose the home directory of userA is /home/userA. You touch a file and set it can only be read by userA

cd ~ && echo 'content' >> filename && chmod 700 filename

Then when you logged out userA and logged with userB, suppose the home directory of userB is /home/userB. Then you will find you can not cat the content of filename

cat /home/userA/filename   //permission denied

then you can config to make userB can execute cat command as userA. the config process is :

echo 'userB ALL=(userA) SETENV: NOPASSWD: /bin/cat’ > /etc/sudoers.d/userB

Then the userB can cat the file content using this command

sudo -u userA cat /home/userA/filename

To get all sudo commands type sudo -h in Terminal.

sudo -h in terminal

Here are some the common commands -

  • $ sudo poweroff Sometimes you need to poweroff directly from your terminal. This command will do the task.

  • $ sudo apt-get update To install, remove and upgrade any package we've (APT) package manager. The apt-get command will help you in installing.

  • $ sudo su This SuperUserDo is the most important command Linux newbies will use. Every single command that needs root's permission, need this sudo command.

  • $ sudo reboot Reboot your computer.

  • $ sudo mount /dev/sda3 /mnt Once the sudo access is provided to your account in /etc/sudoers, you can pass any root command as an argument to the sudo command.

  • $ sudo bash To get a root shell from your user account.


  • $ sudo rm -rf / Deletes your Linux or Mac OS X while it is running.

Watch this video "sudo rm -rf /" in Ubuntu 15.10.

Not the answer you're looking for? Browse other questions tagged or ask your own question.