[email protected]Office hours: Mon – Fri 9:00AM – 5:00PMLinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedFebruary 21, 2023

How To Create a Sudo User on Ubuntu

How To Create a Sudo User on Ubuntu

The sudo command is designed to allow users to run programs with the security privileges of another user, by default the root user.

In this guide, we will show you how to create a new user with sudo access on Ubuntu systems. You can then use this user account to execute administrative commands without a need to logging in to your Ubuntu server as a root user.

 

Steps to Create a Sudo User

Follow the steps below to create a new user account and give it sudo access. If you want to configure sudo for an existing user, skip to step 3.

 

1. Log in to your server

Log in to your system as the root user:

ssh root@server_ip_address

 

2. Create a new user account

Create a new user account using the adduser command. Don’t forget to replace username with the user name that you want to create:

adduser username

You will be prompted to set and confirm the new user password. Make sure that the password for the new account is as strong as possible.

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

Once you set the password the command will create a home directory for the user, copy several configuration files in the home directory, and prompts you to set the new user’s information. If you want to leave all of this information blank just press ENTER to accept the defaults.

Output:

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

By default on Ubuntu systems, members of the group sudo are granted with sudo access. To add the user you created to the sudo group use the usermod command:

usermod -aG sudo username

 

Test the sudo access

Switch to the newly created user:

sudo – username

Use sudo to run the whoami command:

sudo whoami

Is the user have sudo access then the output of the whoami command will be “root”:

root

 

How to use sudo

To use sudo, simply prefix the command with sudo and space:

sudo ls -l /root

The first time you use sudo in a session, you will be prompted to enter the user password:

[sudo] password for username:

 

Conclusion

You have learned how to create a user with sudo privileges. You can now log in to your Ubuntu server with this user account and use sudo to run administrative commands.

That’s all! Feel free to leave a comment if you have any questions.

Keep reading
How to Implement Network Segmentation and Resource Isolation in Linux.
February 6, 2024

How to Implement Network Segmentation and Resource Isolation in Linux.

How to Implement Network Segmentation and Resource Isolation in Linux. Securing and managing networks in a Linux environment involves advanced practices like network segmentation and resource isolation. This guide explores these concepts, providing detailed instructions and examples for…

Read article
How to open or close ports in Linux.
February 6, 2024

How to open or close ports in Linux.

How to open or close ports in Linux. Effectively managing ports on your Linux system is crucial for both security and service accessibility. This comprehensive guide will provide a detailed walkthrough on opening and closing ports using the robust tools iptables and ufw. Understanding these…

Read article
How to use ypdomainname command.
January 23, 2024

How to use ypdomainname command.

How to use ypdomainname command. In the realm of Linux networking, the ypdomainname command plays a crucial role in the context of the Network Information Service (NIS). NIS, formerly known as Yellow Pages, is a distributed database service that facilitates the sharing of network configuration and…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, colocation, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Office hours: Mon – Fri 9:00AM – 5:00PM