This post contains pure hands‑on labs you can run on any Linux system. Every exercise is designed to build confidence through repetition, real‑world scenarios, and structured progression.
You can use Ubuntu, Debian, CentOS, Rocky, AlmaLinux, or any cloud VM. All commands are distribution‑friendly, with alternatives provided where needed.
Preparing Your Environment
Before starting, update your system.
Ubuntu / Debian:
sudo apt update && sudo apt upgrade -yRHEL / CentOS / Rocky / AlmaLinux:
sudo dnf update -yThis ensures your package index and installed software are current.
Lab 1: User & Group Management 👤
Linux uses users and groups to control access. These labs teach you how to create, modify, and delete accounts safely.
1.1 Create a New User
sudo adduser devuserYou’ll be prompted to set a password and optional details.
1.2 Create a New Group
sudo groupadd devteam1.3 Add User to Group
sudo usermod -aG devteam devuser1.4 Verify Group Membership
groups devuser1.5 Create Multiple Users in One Command
for user in user1 user2 user3; do sudo adduser $user -q --disabled-password; done1.6 Delete a User Safely
sudo deluser devuser1.7 Delete a Group
sudo groupdel devteam1.8 Inspect User & Group Files
cat /etc/passwd
cat /etc/groupThese files store account metadata and group definitions.
Lab 2: Permissions & Ownership
Permissions determine who can read, write, or execute files. These labs help you master rwx, chmod, chown, and advanced permission bits.
2.1 Create a Test Directory
mkdir ~/permissions-lab
cd ~/permissions-lab2.2 Create a File
touch file1.txt2.3 View Permissions
ls -l2.4 Change Permissions (Symbolic)
chmod u+rwx,g+rx,o-rwx file1.txt2.5 Change Permissions (Numeric)
chmod 750 file1.txt2.6 Change Ownership
sudo chown $USER:$USER file1.txt2.7 Create a Shared Folder
sudo mkdir /shared
sudo chgrp devteam /shared
sudo chmod 770 /shared2.8 Apply SGID to Shared Folder
This ensures new files inherit the group.
sudo chmod g+s /shared2.9 Set Sticky Bit (Useful for /tmp‑style folders)
sudo chmod +t /shared2.10 Test Permissions with Another User
sudo -u user1 touch /shared/testfileThis confirms group inheritance works.
Lab 3: sudo & Privilege Escalation
sudo allows controlled access to administrative commands.
3.1 Add User to sudo Group (Ubuntu/Debian)
sudo usermod -aG sudo devuser3.2 Add User to wheel Group (RHEL/CentOS)
sudo usermod -aG wheel devuser3.3 Test sudo Access
su - devuser
sudo whoamiExpected output:
root3.4 Grant Specific sudo Permissions
Open sudoers safely:
sudo visudoAdd:
devuser ALL=(ALL) /usr/bin/systemctlThis grants service‑management privileges only.
3.5 View sudo Logs
sudo grep sudo /var/log/auth.logUbuntu:
sudo grep sudo /var/log/auth.logRHEL:
sudo grep sudo /var/log/secureLab 4: Package Management
Package managers install, update, and remove software.
4.1 Install a Package (Ubuntu)
sudo apt install nginx -y4.2 Install a Package (RHEL)
sudo dnf install httpd -y4.3 Remove a Package
Ubuntu:
sudo apt remove nginx -yRHEL:
sudo dnf remove httpd -y4.4 Search for Packages
Ubuntu:
apt search python3RHEL:
dnf search python34.5 Update Package Index
Ubuntu:
sudo apt updateRHEL:
sudo dnf check-update4.6 Upgrade Installed Packages
Ubuntu:
sudo apt upgrade -yRHEL:
sudo dnf upgrade -yLab 5: Managing Services with systemd
systemd controls background services and startup behavior.
5.1 Start a Service
sudo systemctl start nginx5.2 Stop a Service
sudo systemctl stop nginx5.3 Restart a Service
sudo systemctl restart nginx5.4 Check Service Status
systemctl status nginx5.5 Enable Service at Boot
sudo systemctl enable nginx5.6 Disable Service
sudo systemctl disable nginx5.7 View Service Logs
journalctl -u nginx5.8 Create a Custom Service
Create file:
sudo nano /etc/systemd/system/myapp.serviceAdd:
[Unit]
Description=My Custom Python App
[Service]
ExecStart=/usr/bin/python3 /opt/myapp/app.py
Restart=always
User=root
[Install]
WantedBy=multi-user.targetReload systemd:
sudo systemctl daemon-reloadStart service:
sudo systemctl start myappEnable at boot:
sudo systemctl enable myappLAB 6: Managing Default Shells & User Profiles
Understanding shells and login profiles is essential for user management and troubleshooting.
6.1 Check a User’s Default Shell
getent passwd devuserWhat You’re Seeing
The last field shows the shell:
/bin/bash
/bin/sh
/bin/zsh6.2 Change a User’s Shell
sudo chsh -s /bin/bash devuserWhy This Matters
Different shells behave differently. Some users may require bash for scripts or zsh for customization.
6.3 View Login Profile Files
ls -a /home/devuserLook for:
.bashrc.profile.bash_logout
6.4 Add a Login Message
echo "Welcome to the server, devuser!" | sudo tee -a /home/devuser/.bashrcReload:
su - devuserReal‑World Use
Teams often add environment variables, aliases, or warnings to .bashrc.
LAB 7: Advanced Permissions (ACLs)
ACLs (Access Control Lists) allow fine‑grained permissions beyond rwx.
7.1 Install ACL Tools
Ubuntu:
sudo apt install acl -yRHEL:
sudo dnf install acl -y7.2 Set an ACL for a User
sudo setfacl -m u:user1:rwx file1.txt7.3 View ACLs
getfacl file1.txt7.4 Remove an ACL
sudo setfacl -x u:user1 file1.txtWhy ACLs Matter
They allow permissions like:
- “Give user1 read access”
- “Give devteam write access”
- “Give auditors read‑only access”
Without changing ownership.
**LAB 8: sudo Security & Restrictions **
(Real‑World Admin Work)
sudo is more than “run commands as root.” This lab teaches controlled privilege escalation.
8.1 Allow a User to Run Only One Command
sudo visudoAdd:
projectuser ALL=(ALL) /usr/bin/apt8.2 Allow a User to Run Commands Without Password
projectuser ALL=(ALL) NOPASSWD: /usr/bin/systemctl8.3 Deny a User from Running a Command
projectuser ALL=(ALL) !/usr/bin/rm8.4 Log All sudo Commands
sudo grep sudo /var/log/auth.logRHEL:
sudo grep sudo /var/log/secureReal‑World Use
Companies use sudo restrictions to enforce least privilege.
LAB 9: Package Management: Repositories & Caching
Package managers do more than install software.
9.1 Check Installed Repositories
Ubuntu:
ls /etc/apt/sources.list.d/RHEL:
dnf repolist9.2 Add a Repository
Ubuntu:
sudo add-apt-repository universe
sudo apt updateRHEL:
sudo dnf config-manager --set-enabled crb9.3 Clean Package Cache
Ubuntu:
sudo apt cleanRHEL:
sudo dnf clean all9.4 Check Package Info
Ubuntu:
apt show nginxRHEL:
dnf info httpdWhy This Matters
Package metadata helps you understand:
- Dependencies
- Versions
- Maintainers
- Installed files
LAB 10: systemd Advanced: Dependencies, Targets & Timers
systemd is more than start/stop. This lab teaches deeper service management.
10.1 Check Service Dependencies
systemctl list-dependencies nginx10.2 Check Boot Targets
systemctl get-defaultCommon targets:
multi-user.target(servers)graphical.target(desktops)
10.3 Change Boot Target
sudo systemctl set-default multi-user.target10.4 Create a systemd Timer (Cron Replacement)
Create a script:
sudo nano /usr/local/bin/backup.shAdd:
#!/bin/bash
echo "Backup ran at $(date)" >> /var/log/backup.logMake executable:
sudo chmod +x /usr/local/bin/backup.shCreate a timer unit:
sudo nano /etc/systemd/system/backup.timerAdd:
[Unit]
Description=Run backup script every minute
[Timer]
OnCalendar=*:0/1
Unit=backup.service
[Install]
WantedBy=timers.targetCreate the service unit:
sudo nano /etc/systemd/system/backup.serviceAdd:
[Unit]
Description=Backup Script
[Service]
ExecStart=/usr/local/bin/backup.shEnable & Start Timer:
sudo systemctl daemon-reload
sudo systemctl enable --now backup.timerCheck Timer Status:
systemctl list-timersReal‑World Use
Timers replace cron in modern systems.
LAB 11: File Ownership & Permissions in Real‑World Scenarios
This lab simulates a real company environment.
Scenario: A Shared Project Folder
Step 1: Create the folder
sudo mkdir -p /opt/company/projectAStep 2: Create a team group
sudo groupadd projectA-teamStep 3: Assign group ownership
sudo chown :projectA-team /opt/company/projectAStep 4: Give group write access
sudo chmod 2770 /opt/company/projectA2 = SGID Ensures new files inherit the group.
Step 5: Add users to the team
sudo usermod -aG projectA-team user1
sudo usermod -aG projectA-team user2Step 6: Test access
sudo -u user1 touch /opt/company/projectA/test1
sudo -u user2 touch /opt/company/projectA/test2Real‑World Use
This is how engineering teams collaborate on shared codebases.
LAB 12: Troubleshooting Services (Real‑World Debugging)
This lab teaches how to diagnose failing services.
12.1 Check Service Status
systemctl status nginx12.2 Check Logs
journalctl -u nginx --no-pager12.3 Check Port Usage
sudo ss -tulpn | grep 8012.4 Restart the Service
sudo systemctl restart nginx12.5 Reload Configuration Without Restart
sudo systemctl reload nginxReal‑World Use
Reloading avoids downtime.
Final Challenge (Beginner → Intermediate)
This challenge reinforces everything you’ve learned.
Your Task
- Create a user named
projectuser. - Create a group named
projectteam. - Add the user to the group.
- Create
/opt/project. - Assign group ownership to
projectteam. - Apply SGID to the folder.
- Install Apache or Nginx.
- Enable and start the service.
- Document your steps in a text file.
This challenge simulates a real‑world onboarding task for junior engineers.