DEV Community

Cover image for Mastering User Management in Linux: useradd, usermod, passwd and userdel
Sana Muhammad Sadiq
Sana Muhammad Sadiq

Posted on

Mastering User Management in Linux: useradd, usermod, passwd and userdel

Introduction

As I continue my 30-Day Linux Challenge in preparation for the RHCSA exam. Today I’m covering something every system admin must know user management in Linux.

Whether you’re onboarding a new team member, securing a system, or automating access control, creating and managing users is one of the most core tasks you’ll perform.

In this article, I’m walking you through the essentials: creating users, modifying them, assigning passwords and removing accounts safely; all using just the terminal.

Index

  1. Why User Management Matters
  2. Key Commands You Will Use
  3. Practical Examples
  4. Pro Tips
  5. Real World Use Cases
  6. RHCSA Relevance
  7. Quick Summary

πŸ” Why User Management Matters

  • Keeps your system organized and secure
  • Allows team collaboration with controlled access
  • Prevents unauthorized access
  • Critical in production environments, servers and cloud systems

πŸ“Œ Key Commands You Will Use

Command What It Does
useradd Creates a new user
usermod Modifies an existing user
passwd Sets or changes a user password
userdel Deletes a user

βœ… Practical Examples

➀ 1. Creating a New User

sudo useradd CloudWhistler
Enter fullscreen mode Exit fullscreen mode

Creates a user named CloudWhistler.

➀ 2. Creating a User with a Home Directory

sudo useradd -m SanaCW
Enter fullscreen mode Exit fullscreen mode

➀ 3. Setting a Password for a User

sudo passwd SanaCW
Enter fullscreen mode Exit fullscreen mode

➀ 4. Adding a User to a Group

sudo usermod -aG CW SanaCW
Enter fullscreen mode Exit fullscreen mode

➀ 5. Changing a Username

sudo usermod -l SanaRedHat SanaCW
Enter fullscreen mode Exit fullscreen mode

➀ 6. Deleting a User

sudo userdel SanaRedHat
Enter fullscreen mode Exit fullscreen mode

Add -r to remove their home directory too:

sudo userdel -r SanaRedHat
Enter fullscreen mode Exit fullscreen mode

In below image, I have executed all commands as mentioned in the above steps so it's easy to preview and run them one by one.

Image description

🧠 Pro Tips

  • Always use -m to ensure a home directory is created.
  • Use id username to verify user info.
  • Use grep in /etc/passwd to view all user entries.
  • Never delete a user without checking file ownership or system dependencies.

🏭 Real World Use Cases

βœ… Onboarding new developers: useradd + group assignments
βœ… Securing systems: passwd -l to lock unused accounts
βœ… Organized access control: Set up team-based permissions using groups
βœ… Automation: User creation is part of CI/CD scripts and Ansible roles

πŸ§ͺ RHCSA Relevance

You'll be expected to:

  • Create users with home directories
  • Add users to groups
  • Set and change passwords
  • Lock/unlock or delete users

Mastering these commands makes the exam (and real-world tasks) way easier!

βœ… Quick Summary

User management is one of the most practical skills you'll use daily as a Linux professional.

Whether you're securing a production server or setting up a test environment, learning how to confidently create and manage users with these commands is a must-have foundation for your journey.

Image description

I'd love to hear your thoughts, insights or experiences with Linux. Feel free to share and join the conversation [ Connect with me on LinkedIn www.linkedin.com/in/techwithsana ]πŸ’œ

#30dayslinuxchallenge #redhat #networking #cloudcomputing #cloudenginner #cloudarchitect #cloud #RHCSA #RHCE #RHEL #WomeninTech #Technology

Top comments (0)