User Tools

Site Tools


how_to_create_and_delete_users

How to create and delete users

We use sudo adduser username to create a new user
Sudo command must be used by sudoer user only.

If you want to assign the user to a group for example sudo group you can use sudo adduser username sudo

  • How to create a user:

1. Fisrt User: myself

  1. Ordered List ItemFirst make sure your are using a sudoer group user or root to perform sudo command.
  2. Then use sudo adduser aidel
  3. Then you will need to insert your password which i insert aidel as the password
  4. Then you will have to insert the details of the user such as full name, group and phone number
  5. system will ask whether the information is correct or not, if yes press y

EXTRA
Add user aidel to sudo group

  • use sudo adduser username sudo

2. Second User: John Doe

- Ordered List ItemFirst make sure your are using a sudoer group user or root to perform sudo command.

  1. Then use sudo adduser jdoe
  2. Then you will need to insert your password which i insert sysadmin#1 as the password
  3. Then you will have to insert the details of the user such as full name, group and phone number
  4. system will ask whether the information is correct or not, if yes press y

3. Second User: Will Smith

- Ordered List ItemFirst make sure your are using a sudoer group user or root to perform sudo command.

  1. Then use sudo adduser wsmith
  2. Then you will need to insert your password which i insert sysadmin#2 as the password
  3. Then you will have to insert the details of the user such as full name, group and phone number
  4. system will ask whether the information is correct or not, if yes press y

4.Check the user

  1. Use cat /etc/passwd
  2. it will appear the name of the user and the details

  • How to delete user
  1. Use sudo userdel username to delete user.
  2. In this case i use sudo userdel aidel to delete user aidel
  3. Use cat /etc/passwd to check again the list of user
  4. Previously it will display user aidel details now after delete user aidel no longer exist

  • Delete User and Home Directory

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

  • Force Deletion

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

  • Lock User Before Deleting

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

EXTRA

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.

how_to_create_and_delete_users.txt · Last modified: 2025/01/17 16:59 by 1211112319

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki