How to Add User to Sudoers in Ubuntu

Photo of author

By Oluwaseun Bamisile

Published

Do you desire to add a user to sudoers in the Ubuntu Linux-based OS but have no clue how to go about it? This guide is for you, as it illustrates several methods to do that.

Before we move on, you should know that the procedures that will be provided in this guide are based on the Ubuntu 22.04 LTS OS. Hence, the procedures might differ slightly if you use other Ubuntu Linux-based OS versions.

Option 1: Add User to Sudoers Through Settings

One way to grant a user sudo privileges in Ubuntu is through the settings in the Ubuntu GUI. To learn how to do that, follow the procedures listed below.

  1. First, ensure you log into your Ubuntu Linux-based computer using an account with sudo privileges.
  2. Afterward, click the Show Applications icon on the Ubuntu dock. Now, open the settings in Ubuntu by inputting “settings” in the search field and selecting the Settings icon from the search result.
You can also open the settings by clicking the system menu tray at the top right corner of the Ubuntu desktop. Then, select Settings from the options in the system menu tray.
Add User To Sudoers In Ubuntu Through Settings
  1. In the Ubuntu Settings window, select Users among the menus on the left pane.
  1. Following that, click the Unlock… button at the top of the Users page to add users and change settings.
Add User To Sudoers In Ubuntu Through Settings
  1. Accordingly, you will be prompted to input your password for authentication. Hence, input your password in the provided input field, then click the Authenticate button.
  1. Now, select the user you wish to add to sudoers, then turn on the Administrator toggle under Account Settings.
Add User To Sudoers In Ubuntu Through Settings

Option 2: Add User to Sudo Group Through Terminal

Another way you can add a user to the sudo group in Ubuntu is by running a particular command in the terminal. As a matter of fact, there are various commands you can use to add a user to the sudo group in Ubuntu.

However, we will focus on only two commands in this section. These commands are the usermod command and gpasswd command.

Thus, the following sub-sections will show you how to use these commands to grant a user sudo privileges in Ubuntu.

Add User to Sudo Group Using the Usermod Command

  1. Ensure you’re logged into your Ubuntu system as a root user or with an account with sudo privileges. Then, right-click any free area on the Ubuntu desktop and choose Open in Terminal from the context menu.
Add User To Sudo Group In Ubuntu Through Terminal
  1. When the terminal opens, execute the command below. However, replace “username” in the command with the username of the user you wish to add to the sudo group.
sudo usermod -aG sudo username

For instance, if I wish to add a user named “itechguide”, below is what the command should look like.

sudo usermod -aG sudo itechguide
Before the command runs, you will be asked to input your password. Hence, input your password and press the enter key on your keyboard.

Also, note that characters won’t be visible while typing your password in the Ubuntu terminal.
  1. After doing all that, you can confirm if the user has been added to the sudo group by executing the command below. However, replace “username” with the username of the user.
id username

For this demonstration, the username of the user is “itechguide”. So, below is what the command should look like.

id itechguide
Add User To Sudo Group In Ubuntu Through Terminal
  1. After running the prior command, the output should include “27(sudo)”, indicating the user has been added to the sudo group.

Add User To Sudo Group Using the Gpasswd Command

  1. Sign into your Ubuntu computer as a root user or with an account in the sudo group.
  2. Next, open the app menu by clicking the Show Applications icon on the Ubuntu dock. Then, input “terminal ” in the search field and choose the Terminal program from the search result.
Add User To Sudo Group In Ubuntu Through Terminal
  1. In the Ubuntu terminal, type the following command and press the enter key. However, replace “username” with the username of the user you wish to add to sudoers.
sudo gpasswd -a username sudo

For example, if I want to add a user with a username of “John” to the sudoers, below is what the command should look like.

sudo gpasswd -a john sudo
  1. By doing that, you will be prompted to input your password – do so and press the enter key on your keyboard. Hence, the user should be added to sudo group.
Add User To Sudo Group In Ubuntu Through Terminal

Frequently Asked Questions

1. Who is a Sudo user?

A sudo user is a regular Linux user with administrator privileges to run commands and perform tasks as a root user. Basically, a sudo or a root user can do things in Linux that a regular user can’t.

For example, a sudo user can add a new user and also access sensitive files. As a matter of fact, a sudo user can add another user to the sudo group in Linux.

2. How to add a user to the Sudo file in Ubuntu?

To add a user to the sudo file in Ubuntu, follow the steps below.
a) First, ensure you log into your Ubuntu Linux-based computer using an account with sudo privileges.
b) Afterward, click the Show Applications icon on the Ubuntu dock.
c) Now, open the settings in Ubuntu by inputting “settings” in the search field and selecting the Settings icon from the search result.
d) In the Ubuntu Settings window, select Users among the menus on the left pane.
e) Following that, click the Unlock… button at the top of the Users page to add users and change settings.
f) Consequently, you will be prompted to input your password for authentication. Hence, input your password in the provided input field, then click the Authenticate button.
g) Now, select the user you wish to add to sudoers, then turn on the Administrator toggle under Account Settings.

3. What is the Sudo command iUbuntu?

The sudo command in Ubuntu allows sudo users to run commands with root privileges.

4. What is the command to add a user to Sudo in Linux?

The command to add a user to sudo in Linux is “sudo usermod -aG sudo username” (without the quotes). However, “username” in the command should be replaced with the username of the user you wish to add to sudo.

5. What is the full form of Sudo in Linux?

Sudo is the acronym for “superuser do” or “substitute user do”.

Conclusion

Adding a user to sudoers in Ubuntu gives the user administrative/sudo privileges. Thus, the user will be able to perform administrative tasks, run programs as a root user, and execute commands with sudo privileges.

However, only trusted users can be added to the sudo group in Ubuntu. Fortunately, this guide demonstrated multiple methods to add a user to sudoers in the Ubuntu Linux-based operating system.

Precisely, we learned how to execute this task through the settings in the Ubuntu GUI. this guide also taught us two commands to grant a user sudo privileges through the Ubuntu terminal.

Hopefully, you enjoyed this article and found it helpful. If you did, click on “Yes” beside the “Was this page helpful” question below.

You may also express your thoughts and opinions by using the “Leave a Reply” form at the bottom of this page.

Finally, you can visit our Linux how-to page to find other helpful Linux how-to guides.

About the Author

Photo of author

Oluwaseun Bamisile

Oluwaseun is the Lead Content Editor at Itechguides.com. He holds a National Diploma in Computer Science (currently studying part-time for his Higher National Diploma). An internet geek with a love for automobiles, he writes product reviews, tech articles, and how-to guides on the site.

Related Articles

Get in Touch

We're committed to writing accurate content that informs and educates. To learn more, read our Content Writing Policy, Content Review Policy, Anti-plagiarism Policy, and About Us.

However, if this content does not meet your expectations, kindly reach out to us through one of the following means:

  1. Respond to "Was this page helpful?" above
  2. Leave a comment with the "Leave a Comment" form below
  3. Email us at [email protected] or via the Contact Us page.

Leave a comment

Send this to a friend