This is an old revision of the document!
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.
- 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.
Adding user to sudo group
Add user aidel to sudo group using
sudo adduser username sudo
Note: This method may not work in Debian, you can use 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.
- 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.
- Checking the users
1. Type the following command:
cat /etc/passwd
2. It will show the name and details of the users.
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.
- Delete User and Home Directory
Recursively removes the user’s home directory and mail spool.
sudo userdel -r username
- Force Deletion
Forces the removal of the user account, kills processes, and deletes files.
sudo userdel -f username
- Lock User Before Deleting
Locks the user's account before deletion to ensure no one logs in during the process.
Flags for userdel command
User Management
User management in Linux is a critical aspect of system administration. It involves creating, modifying, and managing user accounts and groups to ensure proper access control, system security, and resource allocation. Each user is assigned a unique identity, along with permissions and restrictions.
- Change user password
- login to any sudoer group user or root
- Use sudo passwd username to change user password
- Enter new password then you will be ask to retype you new password
- Password change
- Manage Password aging and expiration
The sudo chage command is used in Linux to manage password aging and expiration policies for a user. It allows administrators to define and control how long a user's password remains valid, enforce password expiration, and specify warnings before password expiration.
- sudo chage [option] username
- sudo chage -l username
Display the current password aging information
- sudo chage -E 2025-12-31 username
Set the account expiration date. The account will be disabled after this date. To set account expiration to never use sudo change -E -1 username
- sudo chage -W 7 username
The user will receive a warning 7 days before the password expires.



