Sudo -u asking for password even when NOPASSWD: ALL is set

Issues related to applications and software problems and general support
Post Reply
organicchemistry_01
Posts: 54
Joined: 2017/08/27 09:48:47

Sudo -u asking for password even when NOPASSWD: ALL is set

Post by organicchemistry_01 » 2021/06/18 12:00:07

As the title says, the /etc/sudoers is just vanilla while the added a new file in /etc/sudoers.d/username

Code: Select all

username ALL:ALL NOPASSWD: ALL
Then I am running:

Code: Select all

sudo -u username systemctl hibernate
How do I stop this from asking a password?

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Sudo -u asking for password even when NOPASSWD: ALL is set

Post by TrevorH » 2021/06/18 14:25:27

username ALL:ALL NOPASSWD: ALL
This says, if you are "username" then you can sudo anything you like without a password.
sudo -u username systemctl hibernate
This says, become "username" and then run systemctl as username. If you don't run that as "username" then it will not match the sudo allow so won't do it.. If you _are_ username then it will let you run systemctl as yourself, thus achieving nothing.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply