Add Sudo Privileges to User
Adding User to the sudo Group
usermod -aG sudo username
Adding User to the sudoers File
EDITOR=nano visudo
No password required
username ALL=(ALL) NOPASSWD:ALL
Limit allowed commands
In the following example, username would only be allowed to use commands mkdir
and rmdir
without a password. All other commands would require a password for sudo
username ALL=(ALL) ALL
username ALL=(ALL) NOPASSWD:/bin/mkdir,/bin/rmdir
Add via seperate sudoers file
The /etc/sudoers.d/
directory allows the use of seperate drop in configuration files if you do not want to edit the main /etc/sudoers
file itself.
echo "username ALL=(ALL) ALL" | sudo tee /etc/sudoers.d/username
Last updated