Welcome to Day 4 of the 30 Days of Linux Challenge. Yesterday we looked at file permissions — today, we go one step deeper by learning how to manage users and groups. This is essential for maintaining security, permissions, and system organization in Linux environments.
📚 Table of Contents
- Why User and Group Management Matters
- Basic User Management Commands
- Working with Groups
- System Files Behind the Scenes
- Try It Yourself
- Why This Matters for DevOps and SysAdmins
Why User and Group Management Matters
Linux is a multi-user operating system. Even if you're the only person using your computer, Linux treats every process, service, and file as owned by a specific user or group.
Knowing how to:
- Create and manage users
- Assign users to groups
- Control who has sudo (admin) access
is absolutely necessary for administrating servers, managing access, and building secure environments.
Basic User Management Commands
Here are the most commonly used commands when managing users:
Command | Description |
---|---|
whoami |
Shows the currently logged-in user |
id |
Displays the user ID (UID) and group info |
adduser |
Adds a new user interactively |
useradd |
Adds a user (more manual options) |
passwd |
Sets or updates a user’s password |
usermod |
Modifies a user account |
deluser |
Deletes a user interactively |
userdel |
Deletes a user (used in scripts) |
Example:
This creates a new user named alex and sets a password.
To give alex admin privileges:
This adds the user to the sudo group, allowing them to run admin commands.
Working with Groups
Groups allow you to manage permissions for multiple users at once.
Command Description
groupadd :: Creates a new group
groups :: Lists groups for a user
usermod -aG :: Adds a user to a group
groupdel :: Deletes a group
Groups are key when working in collaborative environments — such as development teams or departments sharing access to certain files or applications.
System Files Behind the Scenes
Linux stores user and group info in a few important system files:
File Purpose
/etc/passwd Stores basic user info (username, UID, shell)
/etc/group Stores group info
/etc/shadow Stores encrypted user passwords
You can safely view these files using:
cat /etc/passwd
cat /etc/group
But never manually edit these unless you know what you're doing. Use commands like usermod, groupadd, and passwd to make changes instead.
Try It Yourself
Open your terminal and test these out:
- sudo adduser testuser
- sudo passwd testuser
- sudo usermod -aG sudo testuser
- groups testuser
This creates a user, sets a password, and gives them sudo access. Use su - testuser to switch into the account and try a few commands.
To remove the user later:
Why This Matters for DevOps and SysAdmins
User and group management isn't just about adding or deleting accounts. It’s how you:
Enforce role-based access
Implement the principle of least privilege
Control sudo access and automation permissions
Keep systems organized and secure — especially on servers
If you're managing Linux systems on the cloud (AWS, Azure, GCP), this knowledge directly impacts your ability to maintain secure and stable environments.