How to use gpasswd command In Linux
In this approach, we will use the gpasswd command, gpasswd is a user command to administer the group functionality like adding a member to the group, removing a member, etc. For this command, the user should exist in the system, and pass the user name along with the group to add the user to the command.
Command:
sudo gpasswd -a username sudo
Where,
- -a: The option is to add the user to the mentioned group.
Output:
In the above image, we can verify whether the user is added to the sudo group with the id command.
How to Add User to Sudoers in Ubuntu
Sudo is a command line tool in a Unix-based system that allows a regular user to run a command as the superuser or another user. Only the super user is allowed to modify the majority of the System-wide settings and configurations. It is not advisable to run any Linux machine as a super user, so always create a normal user for day-to-day usage. To use the super user privileges we don’t need to log in as root users every time, just provide the sudo rights to a normal user to portray the normal user as a root user. It is often done with the help of Sudo group or sudoers file in Linux systems.
In this article, we will discuss how to add a normal user to the sudoers list so that the normal user can use the Sudo command to perform privileged operations.
Contact Us