Linux Mastery
The Human Knowledge Project
Chapter 15 — Users, Groups & Administration
Why This Chapter Matters
Linux was designed from the beginning as a multi-user operating system.
Whether running on a personal computer, a university server, or a cloud data center, Linux allows multiple users to share the same system securely.
This is possible because Linux carefully controls identities, permissions, groups, and administrative privileges.
Understanding how Linux manages users is essential for anyone who wants to administer or secure a Linux system.
Learning Objectives
Upon completing this chapter, you will be able to:
- explain why Linux is a multi-user operating system
- distinguish between users, groups, and administrators
- identify the purpose of the root account
- understand privilege separation
- display information about users and groups
- explain the purpose of user IDs (UIDs)
- describe how Linux manages user accounts
Introduction
Imagine a computer shared by hundreds—or even thousands—of people.
Each person needs private files.
Each person needs their own settings.
Some people should be allowed to administer the system, while others should only be able to use it.
Linux solves this problem through a carefully designed user management system.
Every action performed on a Linux system is associated with a user identity.
Permissions, ownership, and security all begin with understanding who is using the system.
1. Why Multi-User Design Matters
Linux is designed to support many users at the same time.
Examples include:
- desktop computers
- business servers
- universities
- cloud infrastructure
- web servers
- supercomputers
Each user has an independent identity and a controlled level of access.
Linux separates:
- identities
- permissions
- access rights
- administrative privileges
This separation improves both security and system stability.
2. What Is a User?
A user account represents a person or service on a Linux system.
Each user normally has:
- a username
- a password
- a home directory
- a login shell
- permissions
- files they own
Linux uses user accounts to determine what each person is allowed to do.
Example Usernames
norm
alice
guest
backup
Linux usernames are case-sensitive.
3. Home Directories
Each user normally has a personal home directory.
Examples:
/home/norm
/home/alice
The home directory stores:
- documents
- downloads
- shell configuration files
- personal settings
- user-created files
Most of a user's daily work takes place within this directory.
THKI Memory Aid
User ↓ Home Directory ↓ Personal Files
Think of a home directory as your own private workspace inside Linux.
4. User IDs (UIDs)
Although Linux displays usernames, it actually identifies users internally by numbers.
These numbers are called User IDs, or UIDs.
Display your identity with:
id
Example output:
uid=1000(norm) gid=1000(norm)
Although people remember names such as:
norm
Linux primarily works with the numeric UID.
5. The Root User
The most powerful account on a Linux system is:
root
The root user has unrestricted administrative authority.
Root can:
- modify any file
- install software
- create or remove users
- change system configuration
- manage hardware
- control nearly every aspect of the operating system
This power makes root essential for system administration.
It also makes root potentially dangerous.
6. Why Root Is Dangerous
The root account bypasses almost all permission checks.
A mistake made while working as root can:
- delete important files
- damage the operating system
- remove user data
- weaken system security
For this reason, Linux encourages administrators to use elevated privileges only when necessary.
THKI Insight
The root account is powerful because Linux trusts it completely.
That same trust means mistakes made as root can affect the entire system.
7. Privilege Separation
Linux encourages users to perform everyday work with ordinary user accounts.
Administrative privileges are used only when necessary.
This principle is known as privilege separation.
It helps reduce:
- accidental damage
- software bugs
- malware impact
- security risks
Keeping administrative privileges separate from everyday work is one of Linux's most important security principles.
8. sudo — Temporary Administrative Access
Instead of logging in as root, most Linux systems use:
sudo
which means:
superuser do
Example:
sudo apt update
The command runs with temporary administrative privileges.
After the command finishes, the shell returns to normal user privileges.
This approach is much safer than remaining logged in as the root user.
THKI Memory Aid
Normal User ↓ sudo ↓ Administrator ↓ Task Complete ↓ Normal User
9. User Prompt vs. Root Prompt
The shell prompt indicates the privilege level of the current user.
Normal users typically see:
$
The root user normally sees:
#
This visual difference serves as an important reminder that commands entered at the root prompt have unrestricted administrative authority.
Before pressing Enter, always verify which prompt you are using.
10. Switching Users
Linux allows you to switch from one user account to another.
To switch users:
su username
For example:
su alice
To switch to the root account:
su -
or:
sudo -i
Many Linux distributions discourage direct root logins and instead encourage administrators to use sudo whenever possible.
11. Creating User Accounts
System administrators create new user accounts with the useradd command.
Example:
sudo useradd newuser
To automatically create a home directory:
sudo useradd -m newuser
The -m option creates:
/home/newuser
This provides the new user with a personal workspace immediately.
12. Setting Passwords
After creating a user account, assign a password with:
sudo passwd newuser
The system prompts you to enter and confirm a new password.
To change your own password:
passwd
Strong passwords should be:
- long
- unique
- difficult to guess
Password security remains one of the most important defenses against unauthorized access.
13. The /etc/passwd File
Linux stores user account information in:
/etc/passwd
View it with:
less /etc/passwd
A typical entry looks like:
username:x:UID:GID:comment:home:shell
Each field describes an aspect of the user account.
Although the file contains account information, modern Linux systems do not store password hashes here.
14. The /etc/shadow File
Encrypted password hashes are normally stored in:
/etc/shadow
Unlike /etc/passwd, this file is protected and can normally be read only by the system administrator.
Separating password hashes from publicly readable account information greatly improves security.
THKI Insight
Linux separates account information from password hashes so that ordinary users can identify accounts without gaining access to sensitive authentication data.
15. Groups
Groups allow multiple users to share the same permissions.
Instead of assigning permissions individually to every user, administrators assign users to groups.
Examples include:
- developers
- students
- audio
- video
- printers
Groups simplify administration while making permission management much more consistent.
16. Viewing Group Membership
To display your current groups:
groups
To display another user's groups:
groups username
You can also display detailed identity information using:
id
Example output:
uid=1000(norm) gid=1000(norm) groups=1000(norm),27(sudo)
This command displays:
- your user ID
- your primary group
- supplementary groups
17. Adding Users to Groups
To add a user to another group:
sudo usermod -aG groupname username
Example:
sudo usermod -aG sudo alice
The options mean:
| Option | Meaning |
|--------|---------|
| -a | Append to existing groups |
| -G | Specify supplementary groups |
The -a option is especially important.
Without it, existing group memberships may be replaced instead of preserved.
THKI Memory Aid
User ↓ Group ↓ Shared Permissions
Groups allow many users to share the same access rights without managing each account individually.
18. Common Administrative Groups
Many Linux systems include special-purpose groups.
Examples include:
| Group | Purpose |
|--------|---------|
| sudo | Administrative privileges |
| audio | Sound devices |
| video | Graphics devices |
| lp | Printing services |
On many distributions, users receive administrative privileges simply by becoming members of the:
sudo
group.
This approach provides flexibility while maintaining strong security.
19. Displaying Your Identity
Linux provides several commands for identifying the current user.
Display your username:
whoami
Display detailed identity information:
id
Example output:
uid=1000(norm) gid=1000(norm) groups=1000(norm),27(sudo)
These commands are frequently used when troubleshooting permissions and administrative access.
20. File Ownership
Every file and directory in Linux belongs to:
- a user
- a group
Display ownership information with:
ls -l
Example output:
-rw-r--r-- 1 norm users 2048 Jun 15 notes.txt
Ownership determines who may read, modify, or execute a file.
Understanding ownership is essential for effective permission management.
21. System Accounts
Not every user account represents a person.
Linux creates many special-purpose accounts used by services and background processes.
Examples include:
daemonnobodywww-datasyslog
These accounts improve security by allowing services to operate with only the permissions they require.
Many system accounts cannot log in interactively.
This further limits opportunities for misuse.
22. The Principle of Least Privilege
One of Linux's most important security principles is least privilege.
Users and programs should receive only the permissions necessary to perform their work.
Granting unnecessary administrative access increases the risk of:
- accidental damage
- software bugs
- malware
- unauthorized system changes
THKI Insight
Good administrators do not ask,
"What permissions can I grant?"
They ask,
"What is the minimum permission required?"
23. Real-World Administrative Workflow
A Linux administrator might regularly:
- create new users
- assign passwords
- create or manage groups
- grant
sudoprivileges - review user accounts
- audit permissions
- disable unused accounts
Example workflow:
Create a new user:
sudo useradd -m alice
Assign a password:
sudo passwd alice
Grant administrative privileges:
sudo usermod -aG sudo alice
These three commands illustrate a common administrative task.
24. Security Best Practices
Good Linux administration includes:
- using strong passwords
- limiting root usage
- following the principle of least privilege
- reviewing user accounts regularly
- removing unnecessary privileges
- keeping software updated
Small security practices performed consistently greatly improve overall system security.
Chapter Summary
| Command / Concept | Purpose |
|-------------------|---------|
| whoami | Display current username |
| id | Display user and group information |
| useradd | Create user accounts |
| passwd | Set or change passwords |
| groups | Display group membership |
| usermod | Modify user accounts |
| sudo | Temporary administrative privileges |
| root | Administrative superuser |
| /etc/passwd | User account information |
| /etc/shadow | Protected password hashes |
Key Ideas
Linux security begins with understanding users and permissions.
Every action performed on a Linux system is associated with a user identity.
Understanding:
- users
- groups
- ownership
- administrative privileges
- privilege separation
provides the foundation for secure Linux administration.
Good administrators protect systems by granting only the permissions that are truly necessary.
Practice Exercises
- Display your username using:
- Display detailed identity information:
- Display your current groups.
- View:
- Locate your own user entry.
- Explain the purpose of:
whoami
id
/etc/passwd
- UID
- GID
- Display file ownership using:
- Explain the difference between a normal user and the root user.
- Explain why Linux encourages privilege separation.
- Describe the purpose of the
sudocommand. - If permitted, create a test user and assign a password.
- Add the user to a group.
- Explain why groups simplify administration.
- Describe the purpose of:
- Explain the principle of least privilege in your own words.
- Describe why malware running as the root user is especially dangerous.
- Explain how users, groups, and permissions work together to improve Linux security.
ls -l
/etc/shadow
Looking Ahead
You now understand how Linux identifies users, organizes groups, and protects administrative privileges.
In the next chapter, we will explore Linux networking—how computers communicate, how systems identify one another across a network, and how administrators troubleshoot network connections from the command line.