How to Add User in Ubuntu Server and Desktop

How to Add User in Ubuntu Server and Desktop

Hi techies, today we are going to look into how to create a new user in the Ubuntu server and be able to log in and perform administrative tasks. By default, Linux systems have a root user as the default user with full permission to perform any sort of operation in the Linux system. For security reasons, this user should not be permitted to login remotely as it may be a security breach to a system.

In this guide, am going to take you through how you can add another user to the Ubuntu server and be able to login locally or remotely with the same user. This guide applies to all Ubuntu versions from Ubuntu 16.04, 17.04, 18.04, 20.04 to 22.04.


  • Have an Ubuntu server running either in the cloud or locally.
  • User with sudo privileges.
  • SSH enabled on the server

Login to the Remote Ubuntu Server

If you have your server running in the cloud such as Angani Cloud then login with SSH with the below format.

$ ssh username@Server-IP

If SSH is running on a port that is not 22 (default port) then specify the port with -p.

$ ssh [username]@[Server-IP] -p [port-no]

Create a User in the Ubuntu Server

To create a user in Ubuntu you can use two different commands in different scenarios depending on what you want to achieve. The adduser command provides an interactive window throughout the creation of a new user and a new directory for the user is created in the home directory. On the other hand, useradd command is used to add users but without the user directory being created and is not as interactive as adduser. Therefore, useradd is most preferred, especially for the beginners.

$ sudo adduser techiescode

[sudo] password for collins: 
Adding user `techiescode' ...
Adding new group `techiescode' (1001) ...
Adding new user `techiescode' (1001) with group `techiescode' ...
Creating home directory `/home/techiescode' ...
Copying files from `/etc/skel' ...
New password: 
Retype new password: 
passwd: password updated successfully
Changing the user information for techiescode
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] y

When prompted for password enter your user password. You will be asked to enter and confirm a new password for the new user as well as other metadata. When done, select Y to accept and create a new user.

Test User Login.

We have successfully created/added a new user in the Ubuntu system. Now you need to test if you can login with the newly created user. Instead of login out and signing in again with a new user, just use the su command to change to the new user.

$ su - techiescode 

The output below shows that we can login user techiescode.

Add User To sudo Group

In any Linux system, any user apart from the root has no privilege to perform administrative tasks even by igniting the sudo command. Therefore, the user has to be added to the sudoers file to be able to perform admin roles such as system updates, installation of packages, system upgrades etc.

$ sudo apt update
[sudo] password for techiescode: 
techiescode is not in the sudoers file.  This incident will be reported.

Below is the possible error you may encounter. Some versions may have an error: “Permission denied”.

Below is a line of command you can use to add a user to the sudo group.

$ sudo usermod -aG sudo techiescode
  • usermod(user-modify) – This is a command that tells the system to modify the user.
  • -aG(Add-Group) – Tell the system what usermod command is supposed to do

The user is now added to the sudo group and can perform admin functions.

Test User

Confirm that this user can indeed run administrative-based roles in Ubuntu.

su - techiescode 
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Once you change to your new user, the above information with appear in your terminal instructing that you need to sudo command in running task as root.

$ sudo apt update

[sudo] password for techiescode: 
Hit:1 jammy InRelease
Get:2 jammy-updates InRelease [119 kB]                             
Hit:3 jammy-backports InRelease                                    
Get:4 jammy InRelease [12.9 kB]                                     
Hit:5 stable InRelease                                  
Hit:6 focal InRelease                                         
Get:7 jammy-updates/main amd64 c-n-f Metadata [15.6 kB]            
Get:8 jammy-updates/universe amd64 Packages [991 kB]               
Hit:9 all InRelease                                                             
Hit:10 stable InRelease                                            
Hit:11 stable InRelease                                     
Hit:12 stable InRelease                                         
Get:13 jammy-updates/universe amd64 c-n-f Metadata [22.0 kB]       
Hit:14 jammy InRelease                                
Get:15 jammy-security InRelease [110 kB]                             
Hit:16 stable InRelease                                            
Hit:17 jammy InRelease                   
Get:18 jammy-security/main amd64 c-n-f Metadata [11.4 kB]  
Hit:19 jammy InRelease        
Get:20 jammy-security/universe amd64 Packages [789 kB]
Get:21 jammy-security/universe amd64 c-n-f Metadata [16.7 kB]
Fetched 2,088 kB in 4s (493 kB/s)            
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

Congratulations!! It is working!!!


In this article, we have gone through how you can add new users to the Ubuntu Linux system. Furthermore, how you can use the user in running commands as root user (superuser). To achieve this, we learnt that you need to first have the user a member of the sudo group.

How to secure Apache web server with Let’s Encrypt in Ubuntu

How to Install and Use OpenVPN Client on Ubuntu 20.04

How to Install 3CX Phone System V18.0 in Debian 10

Leave a Reply

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

17 + 10 =