How to Create a New Sudo User on Ubuntu

In Linux and other Unix-like systems, the root account has the highest access rights on the system. It is used specifically for system administration purposes.

The root user (sometimes referred to as the superuser) has all rights or permissions (to all files and programs) in all modes (single or multi-user).

Operating a Linux system especially a server using the root account is considered insecure for several reasons. These include among others the risk of damage from accidents (e.g running a command that erases the filesystem), and running system applications with elevated privileges opening the system to security vulnerabilities. Besides the root account is a target for every attacker.

Read Also: Difference Between su and sudo and How to Configure sudo in Linux

With respect to the above security concerns, it is recommended to use the sudo command to gain root privileges when a system user really needs to. On Ubuntu, the root account is disabled by default and the default account is an administrative account which uses sudo to gain root privileges.

In this short article, we will explain how to create a sudo user on Ubuntu Linux distribution.

Creating a New Sudo User in Ubuntu

1. Log in to your Ubuntu server as the root user.

$ ssh [email protected]_ip_address

2. Next, create a new sudo user using the useradd command as shown, where an admin is a username. In the following command, the -m flag means to create the user’s home directory if it doesn’t exist, -s specifies the user’s login shell and -c defines a comment to be stored in the account file.

$ sudo useradd -m -s /bin/bash -c "Administrative User" admin

3. Create a password for the admin user using the passwd utility and confirm the new user’s password. A strong password is highly recommended!

$ sudo passwd admin
Create New Sudo User in Ubuntu

Create New Sudo User in Ubuntu

4. To enable the user admin to invoke sudo to perform administrative tasks, you need to add the user to the sudo system group using the usermod command as follows, where the -a option means to append user to a supplementary group and -G specifies the group.

$ sudo usermod -aG sudo admin

5. Now test sudo access on a new user account by switching to admin’s account (enter admin’s account password when prompted).

$ su - admin
Switch to Sudo Account

Switch to Sudo Account

6. Once switched to admin user, verify that you can run any administrative task, for example, try to create a directory tree under the / directory by adding sudo to the command.

$ mkdir -p /srv/apps/sysmon
$ sudo mkdir -p /srv/apps/sysmon
Run Administrative Commands Using Sudo

Run Administrative Commands Using Sudo

The following are other guides about sudo that you will find useful:

  1. 10 Useful Sudoers Configurations for Setting ‘sudo’ in Linux
  2. How to Show Asterisks While Typing Sudo Password in Linux
  3. How to Keep ‘sudo’ Password Timeout Session Longer in Linux

That’s all for now. In this guide, we have shown how to create a sudo user on Ubuntu. For more details about sudo, see “man sudo_root“. Do you have any questions or thoughts to share? If yes, reach us via the feedback form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.