How to remove user from being sudoer user in linux

How to remove user from being sudoer user in linux

  • Find out user group identity
    $ #Syntax: id -nG {user-name}
    $ id -nG foo
    $ #OUTPUT: admin foo printer audio

    by default admin and sudo groups are allowed to use sudo command as shown in /etc/sudoers file

  • Now to remove a user from group, you have to user usermod command
    $ #Syntax: usermod -G {groupname1,groupname2,...} {username}
    $ #For example, to keep membership of foo in printer and foo groups only 
    $ #(and remove him from admin and audio groups) run this:
    $ usermod -G foo, printer foo
    $ id -nG foo
    $ #OUTPUT: foo printer
    
  • finally restart sudo service
    $ service sudo restart