O'Reilly logo

LPI Linux Certification in a Nutshell, 3rd Edition by Bruno Gomes Pessanha, James Stanger, Stephen Addison Schneiter, Adam Haeder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

sudo

Syntax

sudo [OPTION]... [-a auth_type] [-c class] [-p prompt] [-u username]

Description

sudo (substitute user do) allows a permitted user to execute a command as the superuser or another user, as specified in the /etc/sudoers file.

Frequently used options

-b

Run the given command in the background.

-uUSERNAME

Attempt to run the command as user USERNAME instead of root.

The sudo command lives somewhere between SUID and su. sudo is used when you want to give certain users (or groups of users) access to run certain commands with elevated privileges (usually as root). Sudo is extremely useful for a number of reasons:

  • You don’t have to hand out the root password to people just so they can run a few commands.

  • It logs every command (completed and attempted).

  • In the /etc/sudoers file, you can limit its use by user account, by group, by machine, or by pathname.

  • The design of /etc/sudoers is such that you can replicate it across multiple systems without modification of the file.

The /etc/sudoers configuration file is a standard text file (like most other Linux configuration files), but the syntax for the rules that define the behavior of sudo is formatted in Extended Backus-Naur Form (EBNF), which is a way to describe the grammar of a language. This is relatively unique to the Linux configuration file world, so your /etc/sudoers file will look quite a bit different than other configuration files you are used to. Because of the security implications of sudo, and the somewhat challenging format ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required