Lesson 04 — Linux Users & Groups
Lesson 04 — Linux Users & Groups
Section titled “Lesson 04 — Linux Users & Groups”Lesson Overview
Section titled “Lesson Overview”Imagine a company with 2,000 employees.
Not everyone should have access to every system or file.
- HR employees should only access HR systems.
- Finance staff should access financial applications.
- Developers should deploy applications.
- System administrators should manage servers.
Linux follows the same principle.
Every person who logs into a Linux system has a User Account, and every user belongs to one or more Groups.
Users and Groups are the foundation of Linux security because they determine who can log in, what they can access, and what actions they are allowed to perform.
Whether you’re managing AWS EC2 instances, Kubernetes nodes, enterprise Linux servers, or cybersecurity labs, you’ll work with Linux users and groups every day.
Learning Objectives
Section titled “Learning Objectives”After completing this lesson, you will be able to:
- Explain Linux users and groups.
- Understand authentication and authorization.
- Differentiate between root and regular users.
- Create, modify, and delete users.
- Manage Linux groups.
- Understand user-related configuration files.
- Apply enterprise identity management best practices.
What is a Linux User?
Section titled “What is a Linux User?”A Linux User represents a person, application, or service that can log in to the operating system.
Every user has:
- Username
- User ID (UID)
- Home Directory
- Default Shell
- Password
- Group Membership
Example:
Username:
studentWhy Users are Important
Section titled “Why Users are Important”Users help Linux:
- Authenticate identities
- Protect files
- Separate workloads
- Apply permissions
- Audit system activity
Without user accounts, Linux would not be able to securely manage access.
Types of Linux Users
Section titled “Types of Linux Users”Linux generally has three types of users.
Root User
Section titled “Root User”The root user is the system administrator.
Capabilities include:
- Install software
- Create users
- Delete users
- Modify any file
- Configure networking
- Manage services
Root has unrestricted access.
Regular Users
Section titled “Regular Users”Regular users perform everyday tasks.
Examples:
student
developer
john
aliceRegular users have limited privileges.
System Users
Section titled “System Users”System users run applications and services.
Examples:
nginx
mysql
postgres
dockerThese users usually cannot log in interactively.
User IDs (UID)
Section titled “User IDs (UID)”Every user has a unique User ID (UID).
Example:
| User | UID |
|---|---|
| root | 0 |
| student | 1000 |
| developer | 1001 |
Linux identifies users internally by UID rather than username.
Root User
Section titled “Root User”The root account has:
UID:
0Root can:
- Read every file
- Modify every file
- Delete any file
- Manage all users
- Shut down the system
Because of its power, administrators should use the root account only when necessary.
Home Directory
Section titled “Home Directory”Each user receives a home directory.
Example:
/home/student
/home/alice
/home/johnThe root user has:
/rootUsers typically store personal files in their home directory.
User Shell
Section titled “User Shell”A user’s shell is the program that interprets commands.
Common shells include:
- Bash
- Zsh
- Fish
- Dash
View your current shell:
echo $SHELLLinux Groups
Section titled “Linux Groups”A Group is a collection of users who share permissions.
Example:
Developers
├── Alice
├── John
└── BobInstead of assigning permissions to every individual user, administrators assign permissions to groups.
Primary and Secondary Groups
Section titled “Primary and Secondary Groups”Each user belongs to:
Primary Group
Section titled “Primary Group”The user’s default group.
Example:
student↓
studentSecondary Groups
Section titled “Secondary Groups”Additional groups providing extra permissions.
Example:
student
↓
docker
↓
sudo
↓
developersViewing Current User
Section titled “Viewing Current User”Display the logged-in user.
whoamiExample output:
studentViewing User Information
Section titled “Viewing User Information”Display user identity.
idExample:
uid=1000(student)
gid=1000(student)
groups=1000(student),27(sudo)View Logged-in Users
Section titled “View Logged-in Users”Display active users.
whoor
wThese commands are useful on multi-user servers.
User Configuration Files
Section titled “User Configuration Files”Linux stores user information in several important files.
/etc/passwd
Section titled “/etc/passwd”Contains:
- Username
- UID
- GID
- Home Directory
- Login Shell
View:
cat /etc/passwd/etc/shadow
Section titled “/etc/shadow”Stores encrypted passwords.
Example:
sudo cat /etc/shadowOnly privileged users can read this file.
/etc/group
Section titled “/etc/group”Stores group information.
View:
cat /etc/groupCreating Users
Section titled “Creating Users”Create a new user.
sudo useradd student1Create a home directory automatically.
sudo useradd -m student1Set a password.
sudo passwd student1Modifying Users
Section titled “Modifying Users”Change a username.
sudo usermod -l newuser olduserChange the home directory.
sudo usermod -d /home/newuser newuserAdd a user to a group.
sudo usermod -aG docker student1Deleting Users
Section titled “Deleting Users”Delete a user.
sudo userdel student1Delete a user and their home directory.
sudo userdel -r student1Creating Groups
Section titled “Creating Groups”Create a new group.
sudo groupadd developersDisplay groups.
getent groupAdding Users to Groups
Section titled “Adding Users to Groups”Add a user.
sudo usermod -aG developers student1Verify:
groups student1Removing Users from Groups
Section titled “Removing Users from Groups”Remove a user.
sudo gpasswd -d student1 developersSudo Privileges
Section titled “Sudo Privileges”Linux administrators rarely log in directly as root.
Instead, they use:
sudoExample:
sudo apt updateThis executes a command with elevated privileges.
Authentication vs Authorization
Section titled “Authentication vs Authorization”Authentication answers:
Who are you?
Authorization answers:
What are you allowed to do?
Linux uses both together to secure systems.
Enterprise Identity Management
Section titled “Enterprise Identity Management”Large organizations integrate Linux with centralized identity systems.
Examples include:
- Microsoft Active Directory
- LDAP
- FreeIPA
- Red Hat Identity Management (IdM)
- Microsoft Entra ID
Benefits:
- Centralized authentication
- Single Sign-On (SSO)
- Easier user management
- Improved security
Linux Users in Cloud Computing
Section titled “Linux Users in Cloud Computing”Cloud virtual machines often use Linux users for administration.
Example:
AWS EC2
ubuntuAmazon Linux
ec2-userRed Hat
ec2-userAzure
azureuserUnderstanding default cloud users is essential for managing virtual machines.
Linux Users in Cybersecurity
Section titled “Linux Users in Cybersecurity”Security teams investigate:
- User logins
- Failed authentication attempts
- Privileged accounts
- Unauthorized users
- Suspicious group memberships
Compromised user accounts are a common attack vector.
Common Commands
Section titled “Common Commands”Current user:
whoamiDisplay identity:
idDisplay logged-in users:
whoDisplay user groups:
groupsDisplay account information:
finger student(if the finger package is installed)
Real-World Example
Section titled “Real-World Example”A new Cloud Engineer joins an organization.
The Linux administrator performs the following tasks:
Create User
↓
Assign Password
↓
Add to Developers Group
↓
Grant Sudo Access
↓
Configure SSH Keys
↓
Verify LoginWithin minutes, the engineer can securely manage Linux servers while following organizational security policies.
Best Practices
Section titled “Best Practices”As a Linux administrator:
- Create individual user accounts.
- Avoid sharing accounts.
- Use groups instead of assigning permissions individually.
- Grant only the permissions users need.
- Use
sudoinstead of logging in as root. - Disable unused accounts.
- Review privileged users regularly.
- Enforce strong password and MFA policies where supported.
These practices improve security, accountability, and compliance.
Key Takeaways
Section titled “Key Takeaways”After completing this lesson, you should understand:
- Linux user types.
- Root vs regular users.
- User IDs (UIDs) and Group IDs (GIDs).
- Primary and secondary groups.
- User management commands.
- Important user configuration files.
- Authentication and authorization.
- Enterprise identity management.
Summary
Section titled “Summary”Linux Users and Groups form the foundation of system security and access control.
By understanding how Linux authenticates users, assigns permissions, and manages group memberships, you’ll be able to securely administer Linux servers in enterprise and cloud environments.
Throughout the rest of this module, you’ll build on these concepts by learning Linux permissions, process management, services, networking, and system administration.
Next Lesson
Section titled “Next Lesson”➡️ Lesson 05 — Linux File Permissions
In the next lesson, you’ll learn how Linux protects files using ownership and permissions, understand read, write, and execute access, explore permission notation, and use commands like chmod, chown, and umask to secure Linux systems.