User Tools

Site Tools


user

This is an old revision of the document!


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.

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.


  • 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 whatsapp_image_2025-01-11_at_23.31.55_6b63b9c6.jpg

  • 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.

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

  • 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
  1. login to any sudoer group user or root
  2. Use sudo passwd username to change user password
  3. Enter new password then you will be ask to retype you new password
  4. 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.

  1. 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.

user.1737188729.txt.gz · Last modified: 2025/01/18 08:25 by 1211112299

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki