Table of Contents

Part 2: How to Create and Delete Users

This page will show you how to create and delete users.

Note: Make sure to enable root and superusers before you proceed to avoid any errors.


How to create a user

This section will show you how to create a user. We will be creating three users: yourself, John Doe and Will Smith.


1. Make sure your account is a sudoer or use a root account to perform sudo command.

2. Then use the following command:

sudo adduser aidel

3. Insert your password. In my case, I use aidel as the password.

4. Then, insert the details of the user such as full name, group and phone number.

5. The system will ask whether the information is correct or not. If yes, then press Enter.

whatsapp_image_2025-01-11_at_23.25.16_49f8450a.jpg whatsapp_image_2025-01-11_at_23.27.10_a5e04d49.jpg whatsapp_image_2025-01-11_at_23.27.36_932162f4.jpg


Adding user to sudo group

Add user aidel to sudo group using

sudo adduser username sudo

whatsapp_image_2025-01-12_at_13.28.50_2303cca1.jpg

Note: This method may not work in Debian, you can use this method instead.


1. Type the following command:

sudo adduser jdoe

2. Then, insert the password. In this case, I inserted sysadmin#1 as the password.

3. The, insert the details of the user such as full name, group and phone number.

4. Press Enter if all is done.

whatsapp_image_2025-01-11_at_23.31.33_e41cae74.jpg whatsapp_image_2025-01-11_at_23.31.55_6b63b9c6.jpg

1. Type the following command:

sudo adduser wsmith

2. Then, insert the password. In this case, I inserted sysadmin#2 as the password.

3. The, insert the details of the user such as full name, group and phone number.

4. Press Enter if all is done.

1. Type the following command:

cat /etc/passwd 

2. It will show the name and details of the users.

whatsapp_image_2025-01-11_at_23.37.20_98252dfd.jpg


How to delete user

This section will show you how to delete users.


1. Type the following command to delete user.

sudo userdel username 

2. In this case, we type the following command to delete user aidel

sudo userdel aidel

3. Type the following to check again the list of users.

cat /etc/passwd

Notice that the user aidel no longer exists.

whatsapp_image_2025-01-12_at_13.20.40_6f6cec9d.jpg whatsapp_image_2025-01-12_at_13.19.59_ab381a49.jpg

Recursively removes the user’s home directory and mail spool.

sudo userdel -r username

Forces the removal of the user account, kills processes, and deletes files.

sudo userdel -f username

Locks the user's account to ensure no one logs in during the process before deletion.

passwd -l username

Flags for userdel command


You have learned how to create and delete users! Click this link to further know how to manage user accounts.