Ubuntu is a multi-user operating system. Multi-user operating system means, it can be used by more than one person at a time while running on a single machine. A multi-user operating system is an operating system that allows multiple users to connect and operate a single operating system. In this tutorial, you will learn How to Add and Delete Users on Ubuntu from the Command line.

You can create a new user account in Ubuntu in two ways:

  1. From Command line
  2. From GUI

How to Add and Delete Users on Ubuntu from the Command line

Prerequisites:

A root user or user with sudo privileges required to add or delete user.

Run the below command in terminal to add a new user. Keep in mind to change preferred username in place of username in terminal.

sudo adduser username

The system will ask you to create a password. Create the New password and Retype new password.

You may also be asked to enter some contact information ( Full Name, Room Number, Work Phone, Home Phone, Other). The password is required, and all other fields are optional. You can just press ENTER to each of these. At last, system will ask, Is the information correct? [Y/n], Enter Y. 

Congratulation, You have added a new user successfully.

If you want the new user to have administrative rights, add the new user to the sudo group.

sudo usermod -aG sudo username

Delete a User in Ubuntu from the Command Line

You can delete the existing user from the command line. There are two ways to remove an existing user from the command line in ubuntu. You can use userdel and deluserto remove an existing user. It is preferred to use deluser 

Prerequisites:

A root user or user with sudo privileges required to remove an existing user.

To remove the existing user, without removing the user files, run the below command in the terminal.

sudo deluser username

To remove the existing user and its home directory and mail spool. Use the below command in the terminal.

sudo deluser --remove-home username

Conclusion

You learned How to Add and Delete Users on Ubuntu 20.04 / 18.04 / 16.04.

Sharing is Caring
Scroll to Top