How to allow sudo without a password
Published: 03 Jan 2013
Suppose you’re setting up an automated task or something similar and it would be nice not to worry about entering a password for sudo.
Here’s how to allow sudo without a password for a specific user (tested on Ubuntu 11.10):
- sudo visudo
- add the following line at the end of the file:
someuser ALL=NOPASSWD: ALL
and exit - now test with something like
sudo ls
and you should not get prompted for a password
For completeness, here’s what the sudoers file should look like (Ubuntu 11.10) when your done with the edit above:
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults
env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
shane ALL=NOPASSWD: ALL
#includedir /etc/sudoers.d