chaunceyzhong chaunceyzhong - 1 year ago 87
Linux Question

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

OS: CentOS 7.When i(root) excute command below,it say that "sudo" group can't find.

[root@localhost etc]# usermod -G sudo chauncey
usermod:“sudo” group doesn't exits

I also check file in /etc/group,and "sudo" doesn't exits in it.So,How can I Create "sudo" group correctly.

Answer Source

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

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download