Adding a user to the sudoers list allows you to give administrative access to regular users. This way, you don't have to share the root password with other users on your system. Adding users to the sudoers list allows them to execute system commands with root privileges.

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.

        sudo adduser bob
    

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.

creating new users Linux

Related: How to Add a User in Linux

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.

        sudo usermod -aG sudo bob
    

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.

        groups bob
    
add users to sudoers list in Linux

Alternatively, you can add bob to the sudoers file using the adduser command.

        sudo adduser bob sudo
    
add sudoers using useradd in Linux

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.

  1. Go to Details from the Settings menu.
    add users to sudoers from Ubuntu settings
  2. Click on Users to access user settings.
    add new sudoers in Linux
  3. Click on Unlock from the top window.
    add users to sudoers via gui
  4. Enter your password when prompted.
    authenticating user account for sudoers in Linux
  5. Click on user bob
    selecting users for sudoers
  6. Change the Account Type to Administrator
    add users to sudoers via GUI

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.