How to Add User as Sudoers using Command Line

Command Syntax:

sudo adduser <username> sudo
Change <username> with your actual username. Above command creates a new user and add it in group named sudo. This group already have sudo privileges defined in /etc/sudoers files.

Example:

The following command will create a new user jack and add it to sudo group. If user already exist, it will simply add them to sudo group.
$ sudo adduser jack sudo 

Add Existing User in sudo Group

You can also use the following command to add existing users to group sudo, where it will get full sudo privileges.
$ sudo usermod -aG sudo <username> 

Remove Existing User from sudo Group

The following command will remove user from group sudo. This will not remove user from system.
$ sudo gpasswd  -d <username> sudo 

Thanks for Visit Here

Comments