Here’s how you can grant administrator roles to Linux users by adding them to the sudoers list.
Create a New User in Linux
You’ll need to create a new user before we can add it to the sudoers list. Let’s create a new user named bob. Log in as root or another user with sudo permissions and run the adduser command.
Type in the necessary details or press Enter to skip fields. Once the user has been created, you are ready to add its username to the sudoers list.
Add Existing Linux Users to Sudoers via Terminal
There are several ways of adding a user to the sudo group. The usermod command allows you to add existing users to groups.
Here, the -a flag stands for the Append operation, and -G specifies the sudo Group. You can verify whether the user bob was successfully added to sudoers via the groups command.
Alternatively, you can add bob to the sudoers file using the adduser command.
Add Linux Users to Sudoers via GUI
You can also add users to the sudoers file graphically using Linux desktop environments. Do the following once the user has been created.
Go to Details from the Settings menu. Click on Users to access user settings. Click on Unlock from the top window. Enter your password when prompted. Click on user bob Change the Account Type to Administrator
Manage User Permissions in Linux
You can add users to the sudoers list in several ways. We’ve illustrated the use of usermod, adduser, and Ubuntu GUI Settings in this guide. Many people prefer editing the /etc/sudoers file to grant administrative privileges to a user. However, editing system files comes with a risk factor that should be taken care of.