Ever wondered how Linux knows:
who can access what, and what they are allowed to do?
That’s not random.
It’s controlled by users and groups — one of the most important concepts in Linux security and DevOps.
Let’s break it down simply.
What is a User in Linux?
A user is an account that interacts with the Linux system.
Every user has:
- Username
- User ID (UID)
- Home directory
- Default shell
Everything in Linux runs under a user identity.
Examples:
- A developer user
- A system admin user
- A service user (like nginx)
What is a Group in Linux?
A group is a collection of users.
Think of it like a team:
- Developers group → devs
- QA group → testers
- Admins group → system administrators
👉 Instead of assigning permissions one by one, you assign them to a group.
This makes Linux scalable and manageable.
Check Current User & Groups
whoami
Shows your current logged-in user.
id
Shows:
- User ID (UID)
- Group ID (GID)
- All groups the user belongs to
groups
Shows all groups of the current user.
Creating a User
sudo useradd john
Creates a new user named john.
Note: This may not create a home directory in some systems.
Better way (recommended on Ubuntu/Debian):
sudo adduser john
👉 Automatically creates home directory + setup
Setting Password
sudo passwd john
Used to set or update user password.
Modifying Users (usermod)
sudo usermod -aG developers john
Adds user john to developers group.
Other examples:
sudo usermod -l newname oldname # rename user
sudo usermod -d /new/home john # change home directory
Deleting Users
sudo userdel john
Removes user only.
Remove user + home directory:
sudo userdel -r john
Managing Groups
Creating a Group
sudo groupadd developers
Deleting a Group
sudo groupdel developers
Important System Files
/etc/passwd
Stores user information:
username:x:UID:GID:comment:home:shell
Example:
john:x:1001:1001::/home/john:/bin/bash
👉 This file contains all users in the system.
/etc/group
Stores group information:
group_name:x:GID:user_list
Example:
developers:x:1002:john,mike
👉 Shows which users belong to which group.
What is sudo?
sudo allows a user to run commands as an administrator (root).
Example:
sudo apt update
Why sudo is important
Linux protects system files.
Normal users cannot modify system-level settings.
👉 sudo gives temporary admin power.
Important sudo concept
- Not every user has sudo access
- Only users in
sudoorwheelgroup can use it
Check your groups:
groups
Real-World Example
In a company server:
- Developers → normal users
- Admins → sudo users
- Services → system users (nginx, docker, etc.)
Each user has restricted access based on role
This keeps systems:
- security
- structure
- control ⚙️
Why User & Group Management Matters
In DevOps and system administration:
You use this to:
- control server access
- manage teams on shared systems
- secure applications
- isolate services
Without it:
Linux systems become unmanageable and insecure
Summary
In this guide you learned:
- What users are in Linux
- What groups are
-
whoami,id,groups -
useradd,adduser -
usermodusage -
userdeland cleanup -
groupadd,groupdel -
/etc/passwdstructure -
/etc/groupstructure - sudo basics
- Real-world DevOps usage
Next Post:
Linux Process Management Explained Simply, (ps, top, htop, kill)
Question for You
Have you ever worked on a shared Linux server where multiple users caused confusion or permission issues?
I’ll show how real systems solve that in Part 5.













