[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
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 startedJune 21, 2023

How to Add and Delete Users on Ubuntu 18.04

How To Add And Delete Users On Ubuntu 18.04

In this tutorial, we will show you how to add and remove users with useradd / adduser and deluser/userdel on Ubuntu 18.04.

To be able to create and remove users, you need to be logged in as root or user with sudo privileges .

 

How To Add User in Ubuntu:

Add a New User from the Command Line

In Ubuntu, there are two command-line tools that you can use to create a new user account: useradd and adduser.

useradd is a low-level utility for adding users, while the adduser a friendly interactive frontend to useradd written in Perl.

To create a new user account named username using the adduser command you would run:

sudo adduser username
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' ...

You will be asked a series of questions. The password is required, and all other fields are optional.

Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
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] 

Finally, confirm that the information is correct by entering Y.

The command will create the new user’s home directory, and copy files from /etc/skel directory to the user’s home directory. Within the home directory, the user can write, edit, and delete files and directories.

By default on Ubuntu, members of the group sudo are granted with sudo access.

If you want the newly created user to have administrative rights, add the user to the sudo group :

sudo usermod -aG sudo username

 

How To Delete a User

Delete a User from the Command Line

There are two command-line tools that you can use to delete a user account: userdel and deluser. On Ubuntu, you should use the deluser command as it is more friendly than the low-level userdel.

To delete the user, without removing the user files, run:

sudo deluser username

If you want to delete the user and its home directory and mail spool, use the --remove-home flag:

sudo deluser --remove-home username

 

Conclusion

In this tutorial, you learned how to add and remove users in Ubuntu. The same commands apply for any Ubuntu-based distribution, including Debian, Kubuntu, and Linux Mint.

Keep reading
How to use df command.
June 13, 2023

How to use df command.

How To Use Df Command. In this article we will show you how to check disk space with df command. Using the df Command The general syntax for the df command is as follows: df [OPTIONS]… FILESYSTEM… When used without any argument, the df command will display information about all mounted file…

Read article
How to use watch command.
June 13, 2023

How to use watch command.

How To Use Watch Command. In this tutorial, we will introduce you to the watch command. watch is used to run any arbitrary command at regular intervals and displays the output of the command on the terminal window. The watch utility is a part of the procps (or procps-ng) package which is…

Read article
How to use Ping command.
June 13, 2023

How to use Ping command.

How To Use Ping Command. In this article, wee will explain how to use ping command. ping is part of the iputils (or iputils-ping) package, which is pre-installed on nearly all Linux distributions. It is also available on Windows, macOS, and FreeBSD. How to Use the Ping Command The syntax for the…

Read article
Get in Touch

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

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

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00