How to Add User to Sudoers in Debian

How to Add User to Sudoers in Debian

Sudo (for superuser do) is a command-line utility that allows users to run commands with root privileges.

It gives users admin-level permissions to run programs on your machine.

Using sudo is more secure than opening a session as root. The root password is protected as sudo prompts for the current user's password.

You can temporarily grant extra privileges to users. The access is removed without changing any password.

This tutorial covers how to add a new user to sudoers in the Debian Linux system.

Steps to Add Sudoers in Debian

1. Log in as the Root User

Before adding a user to your system, log in to your server as the root user:

ssh root@ip_address

In the above line, replace ip_address with the IP address of your server.

2. Add a New User in Debian

You can create a new user with the adduser command as a root user. Append the required user account name to the SSH command:

adduser username

For example, add a new account sudo_user with the command:

adduser sudo_user

The output looks like this:

How to Add User to Sudoers in Debian

The sudo command creates a home directory for the user and copies all the necessary files.

Enter the password for the user account and retype to confirm it.

Set a strong password for accounts with sudo access.

Set a strong password -How to Add User to Sudoers in Debian

In the terminal, you will be prompted to change the user information.

Add the details in the text editor or press Enter to leave the fields blank.

How to Add User to Sudoers in Debian

3. Add User to the Sudo Group

Users that have root privileges can add any account to the sudo group.

Everyone in the group automatically gets sudo access to Debian and Ubuntu operating systems.

Run the command shown below and add a user to the sudo group:

usermod -aG sudo username

The commands consists of the following components:

  • usermod command modifies a user account.

  • -aG is an option that adds the user to a specific group. The -a option adds a user to the group. It does that without removing them from the current groups. The -G option is used to state where to add the existing user.

  • sudo is the group that is appended to the options mentioned above.

  • username is the user account you want to add to the sudo group.

Verify the new Debian sudo user is added to the group with the command:

getent group sudo

The output lists all users in the group.

How to Add User to Sudoers in Debian

4. Verify Sudo Access in Debian

To verify the new user has sudo privileges:

  • Switch to the user account you have created. You can do it by running the command shown below.

    You have to replace the username with the name of your user account-

su - username

Run a command that requires superuser access. For example, sudo whoami will show you that you are the root.

5. Using Sudo

If you want to run a command with root access, type in sudo and enter the required command.

For example, you can view details for the root directory, run the ls tool as the following -

sudo ls -la /root

Enter the user’s password as prompted. The terminal will show the contents of the root directory.

You only have to enter the password once for the same session.

Summary

Sudo allows individual users to run commands that require special privileges, such as linux make user admin or debian useradd. This can be particularly useful when you need to make a user sudo, grant sudo privileges, or allow a user to run specific sudo commands on systems like Ubuntu.


You can revoke access easily after you execute the commands as a root account by editing the sudoers file. Debian's default configuration allows users in the sudo group to run any command via sudo, making it easy for an Ubuntu make user admin or ad user to sudo.


The tutorial covers how you can add users to sudoers in Debian using various methods, including using ubuntu give user sudo and allowing them to run sudo commands. Check out more insightful tutorials on CloudPanel that cover topics such as managing permissions and granting access for different types of users.


Whether you're working with an Ubuntu system or another Linux distribution, understanding how to manage and configure your environment and database is crucial for maintaining security and control over your server. By mastering these techniques, you'll be well-equipped to handle any administrative tasks that come your way.

Nikita S.
Nikita S.
Technical Writer

As a lead technical writer, Nikita S. is experienced in crafting well-researched articles that simplify complex information and promote technical communication. She is enthusiastic about cloud computing and holds a specialization in SEO and digital marketing.


Deploy CloudPanel For Free! Get Started For Free!