How To Create a Sudo User on Ubuntu or Debian 2024

Learn how to create a new user with sudo access on Ubuntu systems with this comprehensive guide. By using the sudo command, you can execute administrative commands on your server with the security privileges of another user, such as the root user, without having to log in as root. Follow our step-by-step instructions to easily set up a new user account and streamline your administrative tasks on Ubuntu.

How To Create a Sudo User on Ubuntu

Steps to Create a Sudo User

To grant sudo access to a new user account, follow these simple steps. However, if you need to configure sudo for an already existing user, you can skip to Step 3.

You might like reading> How to List Users on Linux System.

1.  Log in to your server.

To access your system as the root user, you need to log in.

ssh root@server_ip_address

2. Create a new user account.

To generate a fresh user account, make use of the adduser command and ensure to substitute “username” with the desired username for the account.

adduser username

When setting up a new user account, a prompt will appear asking you to create and verify a password. It is essential to ensure that the password is highly secure and robust.


Adding user `username' ...
Adding new group `username' (1001) ...
Adding new user `username' (1001) with group `username' ...
Creating home directory `/home/username' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully

After setting the password, the command will generate a home directory for the user, transfer multiple configuration files into it, and request you to provide the new user’s details. In case you wish to leave these details empty, simply press ENTER to agree with the default values.


Changing the user information for username
Enter the new value, or press ENTER for the default
    Full Name []:
    Room Number []:
    Work Phone []:
    Home Phone []:
    Other []:
Is the information correct? [Y/n]

3. Add the new user to the sudo group

On Ubuntu systems, sudo group members are typically given sudo access by default. To grant sudo access to the user you have created, you can use the usermod command to add them to the sudo group:

usermod -aG sudo username

Test the sudo access 

Switch to the newly created user:

su - username

To execute the whoami command, utilize sudo:

sudo whoami

If the user possesses sudo privileges, the result of executing the whoami command would display as “root”.



How to use sudo

To utilize the sudo command, all you need to do is add “sudo” followed by a space before the actual command.

sudo ls -l /root

Upon using the ‘sudo‘ command for the first time in a given session, a password prompt will appear, asking you to enter your user password:


[sudo] password for username:


Congratulations on acquiring the knowledge of creating a user with sudo privileges for your Ubuntu server. By following the steps, you can now securely log in with this new user account and utilize sudo to execute administrative commands with ease. This allows you to have more control over your system’s functionality and enhances your server’s security by limiting the number of users with administrative access. Additionally, by using the new account, you can limit the risk of unauthorized access or potentially malicious activity. If you have any further questions or concerns about this process, please don’t hesitate to leave a comment below, and we will be happy to assist you.



Hey there! My name is Alex and I'm a professional content writer. I'm also lucky enough to be part of an amazing trio team! I absolutely love what I do and I'm passionate about creating content that engages, informs, and entertains. Whether it's writing blog posts, website copy, or social media content, I always strive to deliver high-quality work that exceeds expectations.

We will be happy to hear your thoughts

Leave a reply