Linux System Administration

0 of 84 lessons complete (0%)

Lab

Lab 1- User Management

You don’t have access to this lesson

Please register or sign in to access the course content.

Lab 1: User Management

Objective:

  • To understand and practice user management tasks on a Linux system.

Topics Covered:

  1. Creating Users
  2. Modifying User Accounts
  3. Managing User Passwords
  4. Deleting User Accounts
  5. Understanding User Groups
  6. Group Management

Lab Exercises:

Exercise 1: Creating Users

  1. Create a new user account named user1.
  2. Set an initial password for user1.
  3. Verify the creation of the user account.
# Create a new user account named user1
sudo useradd user1

# Set an initial password for user1
sudo passwd user1

# Verify the creation of the user account
id user1

Exercise 2: Modifying User Accounts

  1. Modify the home directory of user1 to /home/users/user1.
  2. Change the default shell for user1 to /bin/bash.
  3. Verify the changes made to the user account.
# Modify the home directory of user1
sudo usermod -d /home/users/user1 user1

# Change the default shell for user1 to /bin/bash
sudo usermod -s /bin/bash user1

# Verify the changes made to the user account
id user1

Exercise 3: Managing User Passwords

  1. Force user1 to change the password on the next login.
  2. Set password aging for user1 to expire in 30 days.
  3. Verify the password-related changes.
# Force user1 to change the password on the next login
sudo passwd --expire user1

# Set password aging for user1 to expire in 30 days
sudo chage -M 30 user1

# Verify the password-related changes
sudo chage -l user1

Exercise 4: Deleting User Accounts

  1. Delete the user account user1.
  2. Ensure that the home directory and files associated with user1 are removed.
# Delete the user account user1
sudo userdel -r user1

# Ensure that the home directory and files associated with user1 are removed
ls /home/users/user1   # This should return an error indicating the directory does not exist

Exercise 5: Understanding User Groups

  1. Create a new group named staff.
  2. Add user1 to the staff group.
  3. Verify the group membership of user1.
# Create a new group named staff
sudo groupadd staff

# Add user1 to the staff group
sudo usermod -aG staff user1

# Verify the group membership of user1
id user1

Exercise 6: Group Management

  1. Create a new user account named user2.
  2. Assign both user1 and user2 to the staff group.
  3. Remove user2 from the staff group.
  4. Delete the staff group.
# Create a new user account named user2
sudo useradd user2

# Assign both user1 and user2 to the staff group
sudo usermod -aG staff user1,user2

# Remove user2 from the staff group
sudo deluser user2 staff

# Delete the staff group
sudo groupdel staff

Lab Documentation:

Provide detailed instructions for each exercise, including command syntax and expected outcomes. Include explanations of the purpose behind each task.

Tips:

  • Explore additional user management commands (usermod, passwd, chage, groupadd, userdel, etc.).