
Linux is a multi-user operating system. Multiple users can work on the same system safely and independently. But how does Linux ensure that one user cannot access another user's data? How does the system control who can read, write, or execute files? How does it maintain security in shared environments?
The answer lies in Users and Groups.
Users and groups form the core of Linux security and access control. Understanding them is essential for system administrators, DevOps engineers, developers, and anyone managing Linux servers.
This guide explains everything clearly from user types to permissions, group management, authentication, and real-world administration.
Every action in Linux is performed by a User Identity (UID).
Linux does not trust names it trusts numbers.
Each user has a unique User ID (UID)
Each group has a unique Group ID (GID)
Permissions and access are controlled using UID and GID.
This structure ensures security and accountability.
Linux classifies users into three main categories.
The root user is the most powerful account in Linux.
Capabilities:
Full system control
Can modify any file
Can create/delete users
Can install/remove software
Can control services
Can override permissions
Root UID = 0
Because of its power, root access must be handled carefully.
System users are created automatically by the system for running services and processes.
Examples:
nginx
mysql
postgres
nobody
daemon
Characteristics:
No login shell (usually)
Used for background services
Improve system security
These users isolate services from each other.
These are human users who log in and work on the system.
Examples:
Developers
Administrators
Operators
Students
Regular users have limited permissions for safety.
A Group is a collection of users.
Purpose:
Share permissions
Manage access easily
Organize users logically
Example:
If five developers need access to a project folder, instead of assigning permissions individually, you create a group and add users to it.
Every user belongs to one primary group.
When a user creates a file, the file automatically belongs to this group.
Users can belong to multiple additional groups.
Used for shared access.
Example:
A developer may belong to:
developers group
docker group
sudo group
Linux stores user and group information in specific system files.
Contains:
Username
UID
GID
Home directory
Shell
Example entry:
john:x:1001:1001:/home/john:/bin/bash
Contains encrypted passwords and security settings.
Only root can access this file.
Contains:
Group name
GID
Members
Example:
developers:x:1002:john,alice
useradd username
useradd -m username
passwd username
userdel username
userdel -r username
groupadd groupname
usermod -aG groupname username
gpasswd -d username groupname
groupdel groupname
Every file in Linux has:
Owner (User)
Group
Permissions
You can check using:
ls -l
Example output:
-rw-r--r-- 1 john developers file.txt
Meaning:
Owner = john
Group = developers
chown user file.txt
chown user:group file.txt
Permissions are assigned for:
Owner
Group
Others
Permission Types:
Read (r)
Write (w)
Execute (x)
Example:
chmod 755 file.sh
Meaning:
Owner → full access
Group → read + execute
Others → read + execute
Permissions protect data and system stability.
Regular users cannot perform administrative actions unless granted sudo access.
Users in sudo group can execute commands as root:
sudo apt update
This ensures controlled privilege escalation.
When a user logs in:
Username checked in /etc/passwd
Password verified using /etc/shadow
UID assigned
Shell loaded
Home directory opened
User session starts
Authentication ensures only authorized users access the system.
Create group → Add developers → Assign folder permissions → All members collaborate safely.
Disable root login → Use sudo users → Limit permissions → Improve security.
Run services using system users → Prevent cross-access → Increase stability.
Avoid direct root login
Use strong passwords
Grant minimal permissions
Use groups for access control
Monitor user activity
Remove unused users
Lock inactive accounts
Users and groups form the backbone of Linux security.
Ans: UID is a unique numeric identifier assigned to each user.
Ans: GID is the unique identifier assigned to a group.
Ans: Root is the superuser with full system control.
Ans: Primary group is default group of a user. Secondary groups provide additional access.
Ans: In /etc/passwd, /etc/shadow, and /etc/group.
Add user to sudo group using usermod -aG sudo username.
Ans: Permissions control read, write, and execute access for owner, group, and others.
Ans: Yes, users can belong to multiple supplementary groups.
Ans: For security. Root has full control and misuse can damage system.
Ans: They control security, access, and system organization.
Users and groups are the identity and security foundation of Linux. They control who can access what, how files are shared, and how systems remain secure in multi-user environments.
Mastering users and groups is essential for Linux administration, DevOps, and server management.