Introduction to Sudo

The Sudo package allows a system administrator to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while logging the commands and arguments.

This package is known to build and work properly using an LFS 12.1 platform.

Package Information

  • Download (HTTP):

  • Download MD5 sum: 4166279cb188ecb6641c7a2ba5f68270

  • Download size: 5.1 MB

  • Estimated disk space required: 53 MB (add 18 MB for tests)

  • Estimated build time: 0.2 SBU (with parallelism=4; add 0.1 SBU for tests)

Sudo Dependencies


Linux-PAM-1.6.0, MIT Kerberos V5-1.21.2, OpenLDAP-2.6.7, MTA (that provides a sendmail command), AFS, libaudit, Opie, and Sssd

Installation of Sudo

Install Sudo by running the following commands:

./configure --prefix=/usr              \
            --libexecdir=/usr/lib      \
            --with-secure-path         \
            --with-env-editor          \
            --docdir=/usr/share/doc/sudo-1.9.15p5 \
            --with-passprompt="[sudo] password for %p: " &&

To test the results, issue: env LC_ALL=C make check |& tee make-check.log. Check the results with grep failed make-check.log.

Now, as the root user:

make install

Command Explanations

--libexecdir=/usr/lib: This switch controls where private programs are installed. Everything in that directory is a library, so they belong under /usr/lib instead of /usr/libexec.

--with-secure-path: This switch transparently adds /sbin and /usr/sbin directories to the PATH environment variable.

--with-env-editor: This switch enables use of the environment variable EDITOR for visudo.

--with-passprompt: This switch sets the password prompt. The %p will be expanded to the name of the user whose password is being requested.

--without-pam: This switch avoids building Linux-PAM support when Linux-PAM is installed on the system.

--with-all-insults: This switch includes all the sudo insult sets. Insults are printed if the user types a bad password, and if enabled in /etc/sudoers. Use --with-insults to have them enabled by default. Various sets of insults can be selected with some other switches.



There are many options to sudo's configure command. Check the configure --help output for a complete list.

Configuring Sudo

Config File


Configuration Information

The sudoers file can be quite complicated. It is composed of two types of entries: aliases (basically variables) and user specifications (which specify who may run what). The installation installs a default configuration that has no privileges installed for any user.

A couple of common configuration changes are to set the path for the super user and to allow members of the wheel group to execute all commands after providing their own credentials. Use the following commands to create the /etc/sudoers.d/00-sudo configuration file as the root user:

cat > /etc/sudoers.d/00-sudo << "EOF"
Defaults secure_path="/usr/sbin:/usr/bin"
%wheel ALL=(ALL) ALL


In very simple installations where there is only one user, it may be easier to just edit the /etc/sudoers file directly. In that case, the secure_path entry may not be needed and using sudo -E ... can import the non-privileged user's full environment into the privileged session.

The files in the /etc/sudoers.d directory are parsed in sorted lexical order. Be careful that entries in an added file do not overwrite previous entries.

For details, see man sudoers.



The Sudo developers highly recommend using the visudo program to edit the sudoers file. This will provide basic sanity checking like syntax parsing and file permission to avoid some possible mistakes that could lead to a vulnerable configuration.

If PAM is installed on the system, Sudo is built with PAM support. In that case, issue the following command as the root user to create the PAM configuration file:

cat > /etc/pam.d/sudo << "EOF"
# Begin /etc/pam.d/sudo

# include the default auth settings
auth      include     system-auth

# include the default account settings
account   include     system-account

# Set default environment variables for the service user
session   required

# include system session defaults
session   include     system-session

# End /etc/pam.d/sudo
chmod 644 /etc/pam.d/sudo


Installed Programs: cvtsudoers, sudo, sudo_logsrvd, sudo_sendlog, sudoedit (symlink), sudoreplay, and visudo
Installed Libraries:,,,,,, and
Installed Directories: /etc/sudoers.d, /usr/lib/sudo, /usr/share/doc/sudo-1.9.15p5, and /var/lib/sudo

Short Descriptions


converts between sudoers file formats


executes a command as another user as permitted by the /etc/sudoers configuration file


is a sudo event and I/O log server


sends sudo I/O logs to the log server


is a symlink to sudo that implies the -e option to invoke an editor as another user


is used to play back or list the output logs created by sudo


allows for safer editing of the sudoers file