linux - 'user is not in the sudoers file' but actually is
2014-07
I have already read a lot of posts about enabling sudo-access for a specific user but those couldn't help me so far.
The situation is:
I'm running Debian Testing. On the system there are only two accounts: 'root' and a user account 'benny'.
The user 'benny' should be able to run commands with root privileges using sudo (of course I installed sudo first), which is why I edited the '/etc/sudoers' file using visudo as follows:
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
benny ALL=(ALL:ALL) ALL #<<<<<<<<<<<<<<< EDIT HERE!
# 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
ALL ALL= NOPASSWD: /usr/sbin/g15daemon
This did not work at all - when issuing the 'sudo' command it keeps saying 'benny is not in the sudoers file. This incident will be reported.' So I added benny to the group 'sudo', as it was often suggested:
usermod -aG sudo benny
After a re-login as 'benny' the command
groups
shows
benny cdrom sudo fuse
which seems fine to me. Also
cat /etc/group | grep sudo
shows
sudo:x:27:benny
However if I try, for example
sudo apt update
it still keeps saying that benny was not in the sudoers-file.
I've really read a lot about this issue and everyone just advices one of the two steps, I mentioned above.
What am I missing here? I gues it's something really stupid, but I do not see it. Any help is appreciated! Thanks in advance!
Have you tried creating a new user and adding that user to the sudo group, to see if that works?
This may help to narrow down where the problem is happening.
note: I had to put this comment in an answer as it requires 50 reputation points to comment. Apologies in advance.
I'm running Ubuntu Server 11.04. It came time to add User to the sudoers file: so I decided to simple add User to the admin group:
usermod -a -G admin user
Then I used visudo to check if admin users had been set to receive sudo privileges. I uncommented the line admin ALL=(ALL) ALL
. And viola!
Nothing happened. I've even tried to add user directly into the sudoers file as user ALL=(ALL:ALL) ALL
, but that failed too.
Ideas?
Defaults env_reset
root ALL=(ALL:ALL) ALL
admin ALL=(ALL) ALL
%sudo ALL=(ALL:ALL) ALL
Can you post the relevant sections of your sudoers file?
Re-posted from the comment below:
[edit]admin should be %admin - Percent signs are used for groups, you could have also just added the user to be in the sudo group [/edit]
One quick thing to try is to run grpconv from a root terminal, be it by
su -c'grpconv'
from a non-root terminal
or actually loggin in as root and entering
grpconv