In this guide you will learn how to create a sudo user on Ubuntu, step by step. The same steps work on Ubuntu 26.04, 24.04, 22.04 and 20.04.

To create a new sudo user in linux, you need to log in with the root user.

Create a sudo user on Ubuntu: quick answer

Quick answer: to create a sudo user on Ubuntu, log in as root (or as a user who already has sudo) and run these two commands. The first one creates the user. The second one adds the user to the sudo group, which gives admin rights. Replace “new_user” with the name you want.

$ adduser new_user

$ usermod -aG sudo new_user

Then check the result with this command:

$ sudo -l -U new_user

Which Ubuntu versions does this guide cover?

This guide shows how to create a sudo user on Ubuntu 26.04, 24.04, 22.04 and 20.04. The steps use adduser, usermod and the sudo group. These are standard on Ubuntu, so the commands are the same on all these versions. The text on your screen can look a little different between versions. The screenshots in this post are from Ubuntu 22.04.

Ubuntu 26.04 LTS was released on 23 April 2026 and is the newest long-term release (checked on 25 Oct 2026; see the official Ubuntu 26.04 release notes). For a new server, check the support dates of your Ubuntu version on the official Ubuntu website.

What is a sudo user?

Before creating a user we will first discuss some basics about the sudo user in Linux.

The sudo user is nothing but the user who has permission to run the Linux commands which can not be executed with the regular user.

That means sudo user in Linux executes the commands which need the root user privilege. Sudo users can also run the commands on behalf of other regular users.

Putty - Login to the server
Putty – Login to the server (Ubuntu 22.04)

Login to the server

To create a new user log into the system with the root user.

You can also execute the same commands which can’t be run with regular users, with the sudo user once you create one.

So for creating the user login to your server with putty with the root user.

Create a user in the Linux (Ubuntu)

You can also execute the same commands which can’t be run with regular users, with the sudo user once you create one

So for creating the user login to your server with putty with the root user.

Create a new user on Ubuntu (Linux)
Create a new user on Ubuntu (Linux) (Ubuntu 22.04)

Create a new user

We will create a user named “new_user”

  • type the ssh command below.

$ adduser new_user

Replace “new_user” with the username you want to add.

Then provide the password for the new_user

  • Then again type the password to confirm the password prompt.
  • After the password, it will ask for some information about the “new_user” like Full name, Room no, Work Phone, Home Phone, etc. Give the required information, or to skip with default values just press Enter.
  • After providing all the necessary information, it will again ask for confirmation, press Y and Enter to confirm the details for the new_user.

Now your new_user is created.

add this user to the sudoers list.

Run the following command to add a user to the sudoers list:

$ usermod -aG sudo new_user

Don’t forget to replace the new_user with your username.

This command will add a user to the sudoers list.

Tip: keep the -a in -aG. It means “append”. If you leave it out, the user is removed from all other groups and stays only in the sudo group.

You can confirm if the user is really added to to the sudoers list or not by the following command

$ sudo -l -U new_user

If you get the output content like:

User new_user may run the following commands on <your_os>:
(ALL : ALL) ALL

Then we can say that the user is successfully added to the sudoers list which means it can run commands which sudo privileges.

You can also see the groups of the user with this command. The word sudo should be in the list:

$ groups new_user

Run the sudo commands with the new sudo user

Logout root user from the server and log in with the new_user

Now you can run any sudo commands with this user. You can also use this user to create new sudo users,

Note: group changes work only in a new login. If the user was already logged in when you added the sudo group, ask the user to log out and log in again.

Add new user with the sudo user

For executing the commands you just need to add the “sudo” word before any command.
Like:

$ sudo adduser new_user2

This will create a new user in the system with the name “new_user2”

Grant the sudo privilege to the user with sudo user

$ sudo usermod -aG sudo new_user2

Now your second user is also a sudo user.

To test the new sudo user, log in as that user and run this command. It asks for the password of the user. The answer should be root:

$ sudo whoami

Remove/ Revoke the sudo permission from the user

If you want to remove the sudo access from the user type the ssh command below

$ sudo gpasswd -d new_user2 sudo
This will remove the sudo access from the user and the user will become a normal/regular user. You can not now run the sudo commands with new_user2.

You can also remove the user from the sudo group with this command. The change works from the next login:

$ sudo deluser new_user2 sudo

Delete a user (optional)

If you do not need the user any more, you can delete the user and the home folder. This deletes the files of the user. Take a backup first.

$ sudo deluser --remove-home new_user2

Use sudo without a password (optional, be careful)

Some people want sudo without a password for scripts. It is less safe. If someone gets into this account, they get full admin rights at once. Use it only if you really need it.

Never edit the file /etc/sudoers with a normal text editor. A mistake can lock you out of sudo. Use visudo, which checks the file before it saves. Create a separate file for the user:

$ sudo visudo -f /etc/sudoers.d/new_user

Add this one line, then save and exit:

new_user ALL=(ALL) NOPASSWD:ALL

To undo it, delete the file:

$ sudo rm /etc/sudoers.d/new_user

Common errors when you create a sudo user on Ubuntu

“new_user is not in the sudoers file”

You see a message that says the user is not in the sudoers file. The exact words can be a little different on different Ubuntu versions. To fix it:

  1. Log in as root or as another sudo user and run usermod -aG sudo new_user.
  2. Ask the user to log out and log in again.
  3. Check with groups new_user that sudo is in the list.

“sudo: command not found”

Some very small server images do not have sudo. Log in as root and install it:

$ apt update

$ apt install sudo

The new user cannot log in with an SSH key

The new user does not have your SSH key yet. Run this command from your own computer, then log in as the new user:

$ ssh-copy-id new_user@server_ip

adduser or useradd?

To create a sudo user on Ubuntu, use adduser. It asks the questions shown above and creates the home folder for you. useradd is a basic command that needs extra options to do the same.

Frequently asked questions

How do I create a sudo user on Ubuntu?

Log in as root and run adduser new_user, then usermod -aG sudo new_user. Check it with sudo -l -U new_user.

How do I give a user sudo access on Ubuntu?

Run usermod -aG sudo username as root or as a sudo user. The user must log in again before it works.

How do I check if a user has sudo rights?

Run groups username and look for sudo in the list. Or run sudo -l -U username.

How do I remove sudo access from a user?

Run sudo gpasswd -d username sudo or sudo deluser username sudo.

Can I use root instead of a sudo user?

You can, but it is safer to work as a normal user with sudo. Many servers also block root login over SSH.

Next steps

Now that you know how to create a sudo user on Ubuntu, you can go on with your server setup:

Leave a Reply

Your email address will not be published. Required fields are marked *