How can I add more users to the "sudoers" file?
My preferred method is to add them to the
sudo group (
admin before Ubuntu 10.04).
In Ubuntu Linux, the
sudo group can run
sudo and it is easy to add someone to that group:
usermod -a -G sudo username
Your mileage may vary with other distros, however, someone thought the group method made more sense than the sudoers file getting itself updatified. Less room for getting it wrong and locking everyone out of being superuser seems to be the reason.
Just edit your sudoers file
sudo visudo -f /etc/sudoers
and add the username like 'uk' without quotes
username ALL = (ALL)ALL
Save and exit would give the access.
visudo opens the sudoers file and has samples for simple situations.
You may have to add option 'NOPASSWD' if user scripts would use commands/binaries which can be run only with "sudo", e.g.
ALL=(ALL) NOPASSWD: ALL
It is also possible to specify group instead of user name. So you need not list each and every user, e.g.
%users localhost=/sbin/shutdown -h now
Add to sudo group (Debian / Ubuntu specific step):
$ sudo gpasswd -a <username> sudo Adding user <username> to group sudo
In Amazon Linux, there is
/etc/sudoers.d and inside it is
cloud-init which contains:
ec2-user ALL = NOPASSWD: ALL # User rules for ec2-user ec2-user ALL=(ALL) NOPASSWD:ALL
So all I did was
cp cloud-init vlad, then edit
vlad and replace all instances of
vlad. Works fine, and it's obviously as it was intended to be done, rather than editing existing files.
just by execute this command by a user which has a sudoer permission :
sudo adduser <username> sudo