How to use the usermod command In Linux
In this method, we will use the usermod command, usermod is a system management command found in every major Linux distribution to modify the information of a user account. Here, we are going to modify the newly created user account by adding the user account to a group called sudo. For this command to work, the given user account should exist in the system, if not create an account with the command (sudo adduser username}.
Command:
sudo usermod -a -G sudo username
Where,
- –a: is used to append the group to the user, if the append flag is not passed it will replace the group passed with the existing groups.
- -G: groups to add the specified user.
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.