How to Add a User to Sudoers on Pop!_OS

When installing Pop!_OS, the user account created during the initial setup has sudo rights. However, there may be a need to add additional sudo users or to remove the access. This is a straightforward process with a few commands.

In the following tutorial, you will learn to add a user to the sudoers group on any current Pop!_OS system.

Prerequisites

  • Recommended OS: Any current Pop!_OS
  • User account: root access

Updating Operating System

Update your Pop!_OS operating system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade

Advertisement


Changing to Root (su)

To create new sudo users, you will need to switch to root using the su command. By default, the root account has no password set, so you will need to set this before you can continue using the following command:

sudo passwd root

Next, you will be prompted to enter your password for your sudo account, then once verified, enter a new root password.

Example:

How to Add a User to Sudoers on Pop!_OS

Now that your root password has been set, switch to root using the following command su:

su

You will be prompted for the root password. Once entered, you will see the username has changed to root.

Example:

How to Add a User to Sudoers on Pop!_OS

Create and User Account on Pop!_OS

The first step is learning how to add a new user account. Ideally, you can grant permission to an existing account, but you will learn to add a user from scratch for the tutorial.

First, create the user account <example username>, replacing the example with the user name you want to add.

sudo adduser <example username>

Example:

sudo adduser josh

After typing this command and pressing the enter key, a prompt will appear for the new user’s password and require you to confirm it. Remember, for anyone with sudoers access, a strong password should be used with uppercase, lowercase, symbols, numeric value, and special characters.

Additionally, you will be prompted for additional information regarding the username you are adding. Fill out the details as best as possible, and you can skip the details if you prefer by pressing the ENTER KEY.

Example:

How to Add a User to Sudoers on Pop!_OS

Once done, type “Y” and press the “ENTER KEY” to proceed.

Confirm the user has been added by running the following command:

cat /etc/passwd

Example output:

How to Add a User to Sudoers on Pop!_OS

Advertisement


Add New User To Sudoers Group on Pop!_OS

In the next part of the tutorial, now that you have learned how to add a user, you can give the new user that you named or an existing username sudoers access by typing the following command:

sudo usermod -aG sudo <example username>

Example using our name we created:

sudo usermod -aG sudo josh

It is a good idea to check if the username was successfully added to the sudoers group. To do this, run the id command:

id <username>

Example using our name we created:

id josh

Example output:

How to Add a User to Sudoers on Pop!_OS

An alternative is to use the gpasswd command as follows:

gpasswd -a <example username> sudo

Example using our name we created:

gpasswd -a josh sudo

Example output:

adding josh to group sudo

Confirm & Test New Sudo User

Now that you have successfully added the user you wanted to have sudo access to, it is time to test the account. This can be done again by using the su command but by adding the username along with the command.

Login to sudo user as follows:

su <example username>

Example using our name we created:

su josh

Now, confirm the username with the sudo command along with whoami:

sudo whoami

You will then be prompted to type in the sudo username you are using and its password. Once entered and confirmed, you will see the following output:

How to Add a User to Sudoers on Pop!_OS

Advertisement


Comments and Conclusion

In the tutorial, you have learned how to add users to your Pop!_OS operating system and add sudo permissions. Overall, this tutorial should work for all supported versions and is recommended only to give permissions to trusted users as they will have access to sensitive files with the permit provided by sudo.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x