Skip to content
Search

Sudo

lastmod 2026-03-22created 2015-02-0611 edits

Modifying sudo permissions

sudo-related permissions are set in the /etc/sudoers file. Do not edit this file with vi; use visudo or sudoedit instead.

Modifying the sudo PATH

The PATH set when using sudo can be changed in the /etc/sudoers file with the following line.

Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

User information

After sudo, the SUDO_GID, SUDO_USER, and SUDO_UID environment variables give you information about the user who ran sudo.

Flags

-H
Stackoverflow: What is the -H flag for pip?
The -H (HOME) option requests that the security policy set the HOME environment variable to the home directory of the target user (root by default) as specified by the password database. Depending on the policy, this may be the default behavior.
-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the user does not have permission to preserve the environment.

How to use

Add user

Setting to allow a specific user to use sudo:

devtainer       ALL=(ALL)       ALL

Add group

Setting to allow all users in a group to use sudo

%wheel        ALL=(ALL)       ALL

Skip password

Setting to skip the password

%wheel        ALL=(ALL)       NOPASSWD: ALL
devtainer        ALL=(ALL)       NOPASSWD: ALL

Mount & UnMount

Setting to allow cd mount and umount with sudo

%users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

See also

Favorite site

author Zer0 sitemap