Day 4 of Learning Linux: Demystifying User Management in Linux 🐧

Table of contents
- User management is one of the core pillars of Linux system administration. Whether you're managing a multi-user server or securing your personal development environment, understanding how users, groups, and permissions work is essential.
- What Is a User in Linux?
- Key Files That Store User Data
- Managing Users: Key Commands
- Groups in Linux
- Switching Between Users
- Sudo: Giving Users Admin Power (With Caution )
- Lock and Unlock User Accounts
- Account Expiration & Info
- Summary Cheat Sheet
- Pro Tips
- What I Learned
- Coming Next…
Published on: 16 May 2025
User management is one of the core pillars of Linux system administration. Whether you're managing a multi-user server or securing your personal development environment, understanding how users, groups, and permissions work is essential.
Today, I dove deep into the world of user management in Linux—and I'm here to break it down for you, step by step.
What Is a User in Linux?
In Linux, everything is a file, and every action is performed by a user. Each user on the system has:
A username
A user ID (UID)
A default group
A home directory
A shell (like bash or zsh)
Users can be human users or system users (used by services like mysql
, nginx
, etc.).
Key Files That Store User Data
Understanding where user info is stored is critical.
File | Purpose |
/etc/passwd | Stores user account information |
/etc/shadow | Stores encrypted passwords and account aging info |
/etc/group | Stores group info |
/etc/gshadow | Stores secure group data (like passwords) |
You can view them with commands like cat /etc/passwd
or less /etc/shadow
(needs root).
Managing Users: Key Commands
➕ Create a New User
bashCopyEditsudo adduser john
This creates the user, home directory, and sets default shell. You'll be prompted to set a password and fill in user info.
Alternate:
bashCopyEditsudo useradd -m john
Flags:
-m
: create home directory-s /bin/bash
: specify shell
Set or Change a User Password
bashCopyEditsudo passwd john
To expire a password (force change at next login):
bashCopyEditsudo passwd -e john
Delete a User
bashCopyEditsudo deluser john
To remove the user's home directory too:
bashCopyEditsudo deluser --remove-home john
Alternative:
bashCopyEditsudo userdel -r john
Groups in Linux
Groups help manage permissions for multiple users. Each user belongs to:
A primary group (usually same as their username)
Supplementary groups (optional extra groups)
Group Management Commands
➕ Create a Group
bashCopyEditsudo addgroup developers
➕ Add a User to a Group
bashCopyEditsudo usermod -aG developers john
-aG
: append to group without removing from others
View Groups for a User
bashCopyEditgroups john
Or:
bashCopyEditid john
Remove a User from a Group
bashCopyEditsudo gpasswd -d john developers
Switching Between Users
To switch to another user:
bashCopyEditsu - john
To return to your session: press Ctrl+D
or type exit
.
Or, use sudo
(if you're in the sudo group):
bashCopyEditsudo -u john command_here
Sudo: Giving Users Admin Power (With Caution )
Users in the sudo
group can run commands as root:
bashCopyEditsudo apt update
To add a user to the sudo group:
bashCopyEditsudo usermod -aG sudo john
Check if you're in the sudo group:
bashCopyEditgroups
Lock and Unlock User Accounts
Lock a user:
bashCopyEditsudo usermod -L john
Unlock:
bashCopyEditsudo usermod -U john
Account Expiration & Info
Set an expiration date for a user:
bashCopyEditsudo chage -E 2025-12-31 john
View user aging info:
bashCopyEditsudo chage -l john
Summary Cheat Sheet
Task | Command |
Add user | adduser <username> |
Delete user | deluser <username> |
Modify user | usermod |
Add group | addgroup <groupname> |
Add user to group | usermod -aG <group> <user> |
Set password | passwd <username> |
Lock account | usermod -L <username> |
Switch user | su - <username> |
Check user info | id <username> |
Pro Tips
Avoid using
root
directly—usesudo
where possible.Always back up before deleting users or modifying access.
Combine user management with file permissions (chmod, chown) for robust security.
What I Learned
Today gave me a much clearer picture of how Linux handles users and groups. The commands might seem intimidating at first, but with hands-on practice, they become second nature.
Managing users is about more than just creating accounts—it's about controlling access, securing your system, and understanding how Linux keeps things organized behind the scenes.
Coming Next…
Tomorrow, I’ll dive into file permissions and ownership—how to use chmod
, chown
, and umask
to control who can read, write, and execute your files.
Stay tuned and follow along for more daily Linux learnings! 🚀
Subscribe to my newsletter
Read articles from Rishav Raj directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Rishav Raj
Rishav Raj
A final year undergrad pursuing B.Tech in computer science and engineering. Also specializing in cloud computing and automation. I have a unique blend of Go-lang development with Python. A DevOps enthusiast learning to automate deployment and infrastructure. Currently building upon development skills.