How to Add and Remove Users on Ubuntu 22.04?

Aug 30, 2022 . Admin



Hi Guys,

This post will give you example of How to Add and Remove Users on Ubuntu 22.04?. you'll learn Users to Add and Remove on Ubuntu 22.04. I’m going to show you about Ubuntu 22.04 on Add and Remove Users. if you have question about Add and Remove Users on Ubuntu 22.04 then I will give simple example with solution.

You can use this post for ubuntu 14.04, ubuntu 16.04, ubuntu 18.4, ubuntu 20.04, ubuntu 21 and ubuntu 22.04 versions.

Use the following steps to add and remove new sudo user on linux ubuntu 22.04 system:

Step 1 – Create a new user account on Ubuntu

Step 2 – Add the new user to the sudo group

Step 3 – Test sudo user account

Step 4 – Removing a User from on Ubuntu Command Line

Step 1: Create a new user account on Ubuntu

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

adduser username
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

Is the user have 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 the deluser command on the command line to remove a user from ubuntu:

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
#Ubuntu