====== Part 2: How to Create and Delete Users ====== This page will show you how to create and delete users. **Note: Make sure to [[installation#Enabling root and superuser on Debian|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**. ----- * **First User: Yourself** 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?nolink&600}} {{:whatsapp_image_2025-01-11_at_23.27.10_a5e04d49.jpg?nolink&600}} {{:whatsapp_image_2025-01-11_at_23.27.36_932162f4.jpg?nolink&600}} ----- ==== 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?nolink&600}} **Note: This method may not work in Debian, you can use [[Sudoers|this]] method instead.** ----- * **Second User: John Doe** 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?nolink&600}} {{:whatsapp_image_2025-01-11_at_23.31.55_6b63b9c6.jpg?nolink&600}} * **Third User: Will Smith** 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. {{:whatsapp_image_2025-01-11_at_23.35.44_5a16cf90.jpg?nolink&600|}} {{:whatsapp_image_2025-01-11_at_23.36.15_47c2b88d.jpg?nolink&600|}} * Checking the users 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?nolink&600}} ----- ===== 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?nolink&600}} {{:whatsapp_image_2025-01-12_at_13.19.59_ab381a49.jpg?nolink&600}} * **Delete User and Home Directory** Recursively removes the user’s home directory and mail spool. sudo userdel -r username {{:screenshot_2025-01-12_191951.png?nolink&600}} * **Force Deletion** Forces the removal of the user account, kills processes, and deletes files. sudo userdel -f username {{:screenshot_2025-01-12_192405.png?nolink&600}} * **Lock User Before Deleting** Locks the user's account to ensure no one logs in during the process before deletion. passwd -l username ----- ==== Flags for userdel command ==== {{:screenshot_2025-01-12_193134.png?nolink&600|}} ----- You have learned how to create and delete users! Click this [[usermanagement|link]] to further know how to manage user accounts.