What do you think? Discuss, post comments, or ask questions at the end of this article. [More about me]

Skip to end of metadata
Go to start of metadata

You may want to give password-less sudo access to specific users of group sudo.  This is already done in many AMIs on AWS for example.

Edit sudoers files

You'll need to edit the sudoers file, which in ubuntu is at /etc/sudoers.  To edit it you should use:

sudo visudo

You'll need to add an entry after the following

#includedir /etc/sudoers.d

The entry to add should be of the form

<username>     ALL=(ALL) NOPASSWD: ALL

See below for an example of a sudoers file with example-user given password-less sudo access. 

/etc/sudoers
#
# 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
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"

# 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

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

# Give myself passwordless sudo
example-user     ALL=(ALL) NOPASSWD: ALL