When I(root) excute "usermod -G sudo chauncey",it say that "sudo group doesn't exist"

In centos, you adduser to wheel group instead of sudo.

usermod - aG wheel username


Sudo is not directly a group. The groups/users having sudoer rights are defined in a configuration file that you can access using sudo visudo. Check out this file to find out how it is configured on your system. Here is a good introduction https://www.garron.me/en/linux/visudo-command-sudoers-file-sudo-default-editor.html.

In your case, you have different ways to give sudo rights to chauncey.

  1. find the group(s) having sudo rights in the sudoers file and add chauncey to one of these groups. For example, say you have this line in sudoers:

    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL 
    

    then, add chauncey to admin with sudo usermod -a -G admin chauncey.

  2. create a new sudo group (sudo groupadd sudo) and add this lines (sudo visudo). Then once again add chauncey to the group

    # the 'sudo' group has all the sudo privileges
    %sudo    ALL=(ALL:ALL) ALL 
    
  3. set a special rule for this user in the sudoers file using the following (note that there is no %, which is used to denote a group):

    chauncey    ALL=(ALL:ALL) ALL 
    

Note that for all the rules I mentioned, I used the default ALL everywhere. The first one is the user(s) allowed, the second one is the host, the third one is the user as you are running the command and the last one is the commands allowed. You can tune your rules if ALL is too broad for your usecase.

Tags:

Linux