Centos 7 - adding a user to sudoers group - still is not in the sudoers file - why?

26,466

Solution 1

My experience is that 'user' needs to log out and in again. Try the 'id' command to see if the system thinks that 'user' is in the wheel group or not.

Solution 2

In stock CentOS 7, wheel is not enabled in the default /etc/sudoers file.

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

Did you uncomment those lines?

Share:
26,466

Related videos on Youtube

Why
Author by

Why

Updated on September 18, 2022

Comments

  • Why
    Why over 1 year
    [user@localhost ~]$ su -
    Password: 
    Last login: ...
    [root@localhost ~]# usermod -aG wheel user
    [root@localhost ~]# exit
    logout
    [user@localhost ~]$ sudo echo 123
    [sudo] password for user: 
    user is not in the sudoers file.  This incident will be reported.
    

    What do I do wrong?

    • Jenny D
      Jenny D almost 7 years
    • Syeda
      Syeda about 3 years
      Linux (and most posix systems) only load your group memberships during login. You'll have to log out and log back in for the system to pick up the change and your user account to be able to run sudo.
  • reinierpost
    reinierpost almost 7 years
    Or you can start a new shell with newgrp wheel.
  • Why
    Why almost 7 years
    %wheel ALL=(ALL) ALL is apparently uncommented by default
  • Andrew Schulman
    Andrew Schulman about 3 years
    Please don't post screenshots of text. Inlcude the text in your answer instead, so it's readable by screen readers and search engines.