How to Add and Remove Users on Ubuntu?

10-Jun-2023

.

Admin

How to Add and Remove Users on Ubuntu?

Hello Friends,

In this article we will cover how to implement how to add and remove users on Ubuntu. you can see how to add and delete users on Ubuntu. you'll learn how to add and delete users in the command line in Ubuntu. let’s discuss how to add modify and remove users in linux.

Adding and Removing Users on Linux Ubuntu 22.04: In this tutorial, we will learn how to add and remove new users on a Linux Ubuntu 22.04 system.

Step 1: Create a new user account on Ubuntu


Execute the following command on the command line to add or create a new sudo user on Ubuntu:

adduser username

Note that:- replace username with the user name that you want to create.

Once the user has been added; the Prompt box will appear to set and confirm the new user password.

Step 2: Add the new user to the sudo group

Use the following command to add the user you created to the sudo group use the usermod command:

usermod -aG sudo username

Step 3: Test sudo user account

Now, Use the following command to switch to the newly created user:

su - username

Use sudo to run the whoami command:

sudo whoami

If the user has sudo access then the output of the whoami command will be “root”:

root

Step 4: Removing a User from on Ubuntu Command Line

Execute the deluser command on the command line to remove a user from Ubuntu:

sudo deluser username

The above-given command will not remove the user files.

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

sudo deluser --remove-home username

I hope it can help you...

#Ubuntu