How to Create and Grant Sudo Access to New User in Pop!_OS

Pop!_OS is a Linux distribution that is gaining popularity for its user-friendly interface and robust performance. Similar to other Linux distributions, it’s important to have administrative privileges for tasks such as software installation, service configuration, and file management. This guide will demonstrate how to add a user to the sudoers list in Pop!_OS, which will grant them the ability to execute commands with superuser privileges.

Understanding sudo in Pop!_OS

Before diving into the process of adding a user to the sudoers list, it’s crucial to understand what sudo is. In Debian-based systems like Pop!_OS, the sudoers file controls which users can execute commands with superuser privileges. By default, only the root user has this capability. However, you can add other users to the sudoers list, granting them the ability to perform administrative tasks. This is particularly important when setting up a new server where multiple users require access.

Switching to the Root Account

To create a new user with sudo privileges in Pop!_OS, you need to log into the root account. This account is created during installation and accessed using a password set by the user. This password is required to create a new sudo user. It’s critical to ensure the root password is secure and used only when necessary, such as when adding new sudo users.

To switch to the root account, use the “su” command in the terminal:

su

After entering the root password, the system will confirm your access to the root account. Once the password is verified, the terminal will display the username as “root,” indicating successful login as the root user.

If you’ve forgotten your root password but have sudo access, you can reset the root password using the following command:

sudo passwd root

Creating a User Account

The process of adding a new user with sudo privileges to a Pop!_OS system begins with creating the user account. This guide will walk you through the steps of creating a new account from scratch.

To create a new user account, use the “adduser” command in the terminal, followed by the desired username. The system will prompt you to enter additional information, such as the user’s full name, password, and contact information. Once you’ve provided this information, a new user account will be created.

adduser <desired username>

After executing the command and pressing enter, the system will prompt you to create a password for the new user account. It’s crucial to choose a strong password to ensure the security of the account. A combination of uppercase and lowercase letters, symbols, numeric values, and special characters is recommended to enhance the password’s complexity and make it harder to guess or crack.

Adding the New User to the Sudoers Group

After creating the user account, the next step is to grant sudo privileges to the new or existing user. To do this, execute the following command:

sudo usermod -aG sudo <desired username>

To verify whether the user has been successfully added to the sudoers group, you can execute the “id” command as shown below:

id <username>

This command will display the user’s details, such as their user ID, group ID, and any additional groups they belong to. If the sudo group is listed, the user has been successfully granted sudo privileges.

Confirming the New Sudo User

Once you’ve added the user to the sudoers group, it’s important to test the account to ensure that sudo privileges have been granted successfully. You can use the “su” command to switch to the user account you just created:

su <desired username>

To verify the username, execute the “sudo whoami” command. This command will display the username of the current user with elevated privileges.

sudo whoami

When you execute the “sudo whoami” command, the system will prompt you to enter the password for the sudo user. After entering the correct sudo username and password, you should receive a confirmation message indicating that the user has been granted sudo privileges and can perform administrative tasks on the system.

Conclusion

By following these steps, you can effectively add a new user to the sudoers group on Pop!_OS, granting them the necessary permissions to execute commands with elevated privileges. Remember, granting sudo privileges should only be done for authorized individuals who require elevated permissions to perform system administration tasks. Additionally, it’s crucial to ensure that all users with sudo access use strong passwords and that access to the account is limited to authorized individuals only.

Your Mastodon Instance
Share to...