What Is Sudo in Linux?

The Sudo command gives some admin privileges to non-admin users

Was this page helpful?

When you run administrative applications in Linux, you use the su command to switch to the super user (root) or you use the sudo command. Some Linux distributions enable the root user, but some do not. In the ones that don't—such as Ubuntu—sudo is the way to go. 

About the Sudo Command

In Linux, Sudo—super user do—allows a system administrator to give certain users or groups of users the ability to run some or all commands as root while logging all commands and arguments.

Sudo operates on a per-command basis. It is not a replacement for the shell. Features include the ability to restrict the commands a user can run on a per-host basis, copious logging of each command to provide a clear audit trail of who did what, a configurable timeout of the sudo command, and the ability to use the same configuration file on many different machines.

Example of the Sudo Command

A standard user without administrative privileges might enter a command in Linux to install a piece of software:

dpkg -i software.deb

The command returns an error because a person without administrative privileges isn't allowed to install software. However, the sudo command comes to the rescue. Instead, the correct command for this user is:

sudo dpkg -i software.deb

This time the software installs. This assumes that a person with administrative privileges has previously configured Linux to allow the user to install software.

Note: You can also configure Linux to prevent some users from being able to use the sudo command.