Practice Linux commands on a persistent virtual host. Navigate and edit files, filter text, manage permissions and identities, inspect processes, install packages, operate services, troubleshoot logs and networking, write Bash scripts, and complete a capstone without installing Linux.
Linux Lab TerminalVirtual Ubuntu-style host and Bash teaching shell
linux-lab · student
Lesson 01 - Orientation
A complete virtual Linux host inside one HTML file
The terminal models an Ubuntu-style host, a hierarchical filesystem, users, groups, permissions, processes, packages, services, network interfaces, logs, archives, and Bash scripts. It is designed for command practice and operational reasoning without changing the student computer.
Read the shell promptUnderstand the simulation boundaryUse command historyReset or export work
1
What the simulator maintains
State changes are visible across commands and browser sessions
FS
Virtual filesystem
Files and directories have paths, owners, groups, permission modes, timestamps, and editable contents.
PID
System state
Processes, jobs, services, packages, users, groups, interfaces, routes, and logs are tracked as lab objects.
LAB
Learning evidence
Missions recognize commands and resulting state, while quizzes and lesson completion contribute to progress.
Important simulation boundary
No operating-system command is executed on the host computer. Package installation, service control, network traffic, user creation, and file changes occur only in the in-page model.
2
First five minutes
Learn the terminal controls before changing the system
01
Ask for the supported command set
The help command groups the implemented shell, file, identity, process, service, network, storage, and lab commands.
help
02
Confirm identity and location
A Linux prompt summarizes user, host, and working directory. Verify them instead of assuming.
whoami && hostname && pwd
03
Inspect the starting directory
Long format displays permissions, ownership, size, time, and names. The -a option includes hidden entries.
ls -la
04
Read the welcome file
Use cat for short text files and less for longer material.
cat README.md
05
Review command history
The Up and Down keys navigate history; the history command prints it.
history
Knowledge check
What is the most important limitation of this page?
Lesson 02 - Navigation
Move through the Linux directory tree with confidence
Paths are the addressing system of Linux. Practice absolute paths, relative paths, home-directory shorthand, parent navigation, and directory inspection before using commands that modify data.
Use absolute and relative pathsInterpret . and ..List directory contentsCreate a workspace
1
Path concepts
Every file and directory has one location below the root directory
Notation
Meaning
Example
/
Filesystem root
cd /
~
Current user home directory
cd ~/labs
.
Current directory
find . -name "*.txt"
..
Parent directory
cd ..
Absolute path
Begins at root and does not depend on the current directory
/var/log/auth.log
Relative path
Resolved from the current directory
notes/todo.txt
2
Guided navigation lab
Create and inspect a controlled lab hierarchy
01
Print the working directory
pwd answers the first troubleshooting question: where am I?
pwd
02
Create nested directories
mkdir -p creates any missing parents and does not fail when the path already exists.
mkdir -p ~/labs/linux/navigation/reports
03
Change directory and verify
Use a compound command so the second command runs only if cd succeeds.
cd ~/labs/linux/navigation && pwd
04
Compare normal and long listings
The same directory can be viewed at different levels of detail.
ls
ls -lah
05
Visualize the hierarchy
tree is useful for compact directory-structure review.
tree ~/labs/linux
Before destructive commands
Run pwd and ls before rm, mv, permission changes, or bulk operations. Context mistakes are a common source of damage.
Knowledge check
Which path is interpreted the same way regardless of the current directory?
Lesson 03 - Files
Create, copy, move, link, edit, and remove files
Linux tools are intentionally composable. Learn the difference between file content, file names, directory entries, copies, moves, symbolic links, and recursive removal.
Create filesCopy and move safelyUse symbolic linksEdit in the browser
1
Object operations
Choose the command that matches the intended state change
NEW
Create
touch, redirection, and an editor can create files; mkdir creates directories.
COPY
Duplicate
cp makes another directory entry with copied content. Use -r for directories.
MOVE
Rename or relocate
mv changes a path without keeping the old name.
LINK
Reference
ln -s creates a symbolic link that points to another path.
2
Guided file lab
Build a small document set and inspect each change
01
Create files with touch and redirection
touch creates an empty file; redirection writes command output into a file.
cd ~/labs/linux && touch inventory.txt
echo "router,online" > inventory.txt
02
Append without replacing
Two greater-than signs append to existing content.
echo "database,maintenance" >> inventory.txt
cat -n inventory.txt
03
Copy and rename
Make a backup, then rename the working copy.
cp inventory.txt inventory.bak
mv inventory.txt systems.csv && ls -l
04
Create and inspect a symbolic link
The link has its own name but resolves to the target file.
ln -s systems.csv current-systems.csv
ls -l current-systems.csv && readlink current-systems.csv
05
Edit the file
nano and vi open the same in-browser virtual editor.
nano systems.csv
06
Remove only the backup
Use an explicit path and verify the result.
rm inventory.bak && ls -la
Knowledge check
Which command preserves the original file while creating another copy?
Lesson 04 - Text tools
Read, search, transform, and summarize text
Much of Linux administration is text processing. Combine small commands to inspect configuration, filter logs, count records, select fields, sort values, and remove duplicates.
Read portions of filesSearch with grepCount with wcTransform tabular text
1
Common text-processing roles
Select the smallest command that answers the question
Question
Command family
Typical example
What is in the file?
cat, less
less /var/log/auth.log
What are the first or last records?
head, tail
tail -n 20 FILE
Which lines match?
grep
grep -in "error" FILE
How many lines or words?
wc
wc -l FILE
Which delimited field matters?
cut
cut -d, -f1 FILE
What values repeat?
sort, uniq
sort FILE | uniq -c
2
Log-analysis practice
Use existing simulated authentication and application logs
01
Read recent authentication events
tail is usually more efficient than reading an entire growing log.
tail -n 8 /var/log/auth.log
02
Find failed attempts with line numbers
The -i option ignores case and -n includes source line numbers.
grep -in "failed" /var/log/auth.log
03
Count matching records through a pipeline
grep emits matching lines and wc -l counts them.
grep -i "failed" /var/log/auth.log | wc -l
04
Extract service names from CSV data
cut selects a field based on a delimiter.
cut -d, -f1 ~/data/services.csv
05
Build a frequency table
Sort related values before uniq -c groups adjacent duplicates.
cut -d, -f2 ~/data/services.csv | sort | uniq -c
Knowledge check
Why is sort normally placed before uniq -c?
Lesson 05 - Shell composition
Connect commands with redirection, pipelines, globbing, and conditions
The shell coordinates programs. It expands variables and wildcard patterns, routes standard output, connects one command to another, and decides whether later commands should run.
The fallback message runs because the requested file does not exist.
cat missing-report.txt || echo "report not found"
Knowledge check
Which operator appends output without replacing the existing file?
Lesson 06 - Permissions
Control read, write, and execute access
Each filesystem object has permissions for its owner, group, and everyone else. Practice symbolic and octal modes, ownership changes, default permissions, and the different meaning of execute on files and directories.
Read mode stringsUse chmodChange ownershipReason about least privilege
1
Reading a mode
The first character is object type; the remaining nine are three permission triplets
sudo is required to change ownership in the simulation.
sudo chgrp analysts audit.sh && ls -l audit.sh
06
Review the default mask
umask removes permissions from defaults for newly created objects.
umask
umask 027 && touch masked.txt && ls -l masked.txt
Knowledge check
What does mode 640 grant?
Lesson 07 - Identity
Manage users, groups, and privilege boundaries
Linux authorization decisions depend on numeric user and group identities even when commands display names. Use identity commands, create a service account, place users in groups, and distinguish ordinary operations from administrative ones.
Inspect identityCreate users and groupsManage membershipsUse sudo deliberately
1
Identity sources
Account databases and the current process identity work together
UID
User identity
id displays UID, primary GID, and supplementary groups.
GRP
Group membership
Groups provide shared access without granting ownership to every individual.
SUDO
Administrative elevation
sudo applies root privilege to one approved command in this simulation.
2
Account-management lab
Create a least-privilege application identity
01
Inspect your current identity
Compare the concise user name with complete identity data.
whoami && id && groups
02
Review account files
Account names map to numeric identifiers and home directories.
tail -n 6 /etc/passwd
cat /etc/group | tail -n 6
03
Create a team group
Group creation is an administrative operation.
sudo groupadd appops
04
Create a service user
The -m option creates a home directory and -s selects a shell.
sudo useradd -m -s /bin/bash appsvc
05
Add membership without replacing existing groups
The -a and -G options are normally used together.
sudo usermod -aG appops appsvc
06
Verify the new identity
Inspect the user, group, and home directory state.
id appsvc && ls -ld /home/appsvc
Privilege principle
Use elevated privilege only for commands that require it. A long-lived root shell increases the consequences of path mistakes and untrusted input.
Knowledge check
Why is usermod -aG appops appsvc preferred over using -G alone?
Lesson 08 - Processes
Observe processes, create jobs, and send signals
A running program is a process with an identity, parent, state, command, and resource use. Shell jobs are processes associated with an interactive shell. Learn to inspect them before using signals.
Read process listingsLaunch background jobsUse jobs and fgTerminate deliberately
1
Process evidence
Different commands provide different views of the same running system
Command
Best use
Important fields
ps
Snapshot of selected processes
PID, PPID, user, state, command
ps aux
Broad system snapshot
CPU, memory, start time, command
top
Sorted resource-use teaching view
CPU, memory, load, process state
jobs
Jobs started from this shell
Job number, state, command
kill
Send a signal to a PID or job
TERM by default; KILL only when required
2
Process-control lab
Start a background task and investigate it
01
Review the process table
Use a wide process listing and filter for familiar services.
ps aux
ps aux | grep sshd
02
Start a background job
A trailing ampersand returns control to the shell while the process remains active.
sleep 300 &
03
List shell jobs and processes
Compare job identifiers with operating-system PIDs.
jobs
ps -ef | grep sleep
04
Send a normal termination signal
Use the PID shown by ps. The guided simulator also accepts kill %1.
kill %1
05
Confirm the result
Evidence should show the job no longer running. The final message makes the expected empty process search explicit.
jobs; ps aux | grep sleep || echo "No sleep process remains."
06
Review resource summary
top produces a stable teaching snapshot rather than live host measurements.
top
Knowledge check
Which signal should normally be tried before an uncatchable KILL signal?
Lesson 09 - Packages and services
Install software and control long-running services
Packages place managed files on a system; services run background workloads under a service manager. The page simulates an APT package database and selected systemd service states.
Query packagesInstall a packageInspect service statusEnable and restart services
1
Package state versus service state
Installation does not necessarily mean a service is running
PKG
Package manager
apt resolves package names and records installed versions in the simulated database.
UNIT
Service unit
systemctl starts, stops, restarts, enables, disables, and reports unit state.
LOG
Service journal
journalctl -u UNIT displays messages associated with a service.
2
Service operations lab
Install and operate a small web service
01
Refresh package metadata
The update operation changes only the virtual package index.
sudo apt update
02
Install nginx
Package state and a service unit are created in the lab model.
sudo apt install nginx
03
Verify package installation
Use both the package list and the lower-level package table.
apt list --installed | grep nginx
dpkg -l | grep nginx
04
Inspect and start the service
Status reports whether the unit is loaded, active, and enabled.
systemctl status nginx
sudo systemctl start nginx
05
Enable it for boot and restart
Enablement and current activity are separate attributes.
sudo systemctl enable nginx
sudo systemctl restart nginx
06
Read service logs and listening sockets
Correlate journal evidence with a network listener.
journalctl -u nginx -n 10
ss -tulpn | grep :80
Knowledge check
What does systemctl enable nginx primarily change?
Lesson 10 - Networking
Inspect addresses, routes, names, listeners, and application reachability
Network troubleshooting is most effective when it proceeds from local configuration to name resolution, route selection, transport listeners, and application-layer tests.
Inspect interfacesRead routesResolve namesTest listeners and HTTP
1
Layered investigation sequence
Move from configuration toward the application
Question
Command
Example evidence
What addresses are assigned?
ip addr
Interface state and IPv4/IPv6 addresses
Where will traffic go?
ip route
Default gateway and connected routes
Can a name be resolved?
dig or nslookup
A or AAAA answer
Is a port listening?
ss -tulpn
Protocol, address, port, process
Does the application respond?
curl
Status, headers, and response body
2
Network diagnosis lab
Collect evidence about the simulated host and services
01
Inspect local addresses and routes
Verify link state, addresses, and default route.
ip addr
ip route
02
Review resolver configuration
The resolver file identifies the simulated DNS server.
cat /etc/resolv.conf
03
Resolve a training hostname
dig and nslookup return stable lab records.
dig training.local
nslookup db.training.local
04
Test basic reachability
ping demonstrates name resolution and ICMP-style response in the model.
ping -c 3 training.local
05
List listeners
Look for SSH and any service started in the package lesson.
ss -tulpn
06
Request an application endpoint
curl reports an HTTP-style response from a running nginx service.
curl -I http://localhost
curl http://training.local/health
Reachability is not authorization
A successful route, ping, or TCP connection does not prove that an application request is authenticated, authorized, encrypted, or safe.
Knowledge check
Which command best confirms that a process is listening on TCP port 80?
Lesson 11 - Storage
Measure usage, archive data, and preserve recoverability
Storage work combines capacity checks, directory-level usage, block-device awareness, filesystem mounts, and archive operations. Deletion and extraction should always be preceded by path and content verification.
Read df and duInspect block devicesCreate archivesExtract safely
1
Storage questions
Capacity and directory consumption are related but different
DF
Filesystem capacity
df -h reports total, used, available, and mount location for filesystems.
DU
Directory consumption
du -sh PATH estimates space used by a path hierarchy.
BLK
Block devices
lsblk shows disks, partitions, filesystems, and mount points.
TAR
Archives
tar combines many paths into one archive and can optionally compress it.
2
Backup-and-restore lab
Archive a report directory and verify its contents
01
Measure filesystem and home usage
Use df for mounted capacity and du for a selected hierarchy.
df -h
du -sh ~/labs
02
Inspect devices and mounts
The model includes a root volume and a mounted data volume.
lsblk
mount
03
Create files to archive
Prepare a small source directory with two records.
The c, z, and f options create a gzip-compressed tar archive.
cd ~/labs/linux && tar -czf backup-source.tar.gz backup-source
05
List archive contents before extraction
The t option inspects paths without writing them.
tar -tzf backup-source.tar.gz
06
Extract into a deliberate target
Use -C to avoid scattering files into the current directory.
mkdir -p restore && tar -xzf backup-source.tar.gz -C restore
tree restore
Knowledge check
Which command answers how much space a particular directory hierarchy consumes?
Lesson 12 - Bash scripting
Turn repeated commands into controlled automation
A script records commands, variables, parameters, tests, loops, and exit behavior. The embedded script runner supports a practical teaching subset of Bash and uses the same virtual filesystem as the terminal.
Create executable scriptsUse variables and parametersWrite conditions and loopsCheck exit status
1
A small operational script
The script accepts a service name and reports its state
check-service.sh#!/usr/bin/env bash
SERVICE=${1:-ssh}
echo "Checking $SERVICE"
if systemctl is-active --quiet "$SERVICE"; then
echo "$SERVICE is active"
else
echo "$SERVICE is not active"
fi
for FILE in /var/log/*.log; do
echo "log: $FILE"
done
2
Script authoring lab
Create, inspect, execute, and debug a Bash script
01
Create a script in the editor
Copy the provided starter into the lab directory, then open it to review or modify the implementation.
cd ~/labs/linux && cp ~/examples/check-service.sh . && nano check-service.sh
02
Inspect before execution
Review content and permissions before trusting a script.
cat -n check-service.sh && ls -l check-service.sh
03
Make it executable
Execute permission controls direct invocation.
chmod u+x check-service.sh
04
Run with an argument
The first positional parameter becomes the requested service name.
./check-service.sh nginx
05
Run explicitly through Bash
Using bash does not require the file execute bit, though the file must be readable.
bash check-service.sh ssh
06
Trace commands for debugging
The -x option prints expanded commands as the script executes.
bash -x check-service.sh nginx
Automation amplifies both correctness and mistakes
Validate input, quote variable expansions, use deliberate paths, check command results, and avoid placing secrets directly in scripts or command history.
Knowledge check
Why should a script usually quote a path variable such as "$FILE"?
Lesson 13 - Security and troubleshooting
Collect evidence before changing a Linux system
Reliable administration separates symptoms from causes. Use identity, process, service, network, storage, permission, and log evidence to narrow the problem, then apply the smallest reversible change.
Follow a diagnostic sequenceCorrelate logs and stateDetect permission issuesAvoid destructive first steps
1
Nine-question playbook
A repeatable order reduces guesswork
1
What exactly failed?
Record the command, error text, time, user, host, and expected behavior.
2
What identity and directory are active?
Use id, pwd, and relevant ownership checks.
3
Does the required object exist?
Use ls, stat, package queries, or service-unit queries.
4
What state is it in?
Inspect process, job, service, mount, listener, and route state.
5
What did logs report?
Use targeted journalctl, tail, and grep queries.
6
Do permissions allow the operation?
Evaluate owner, group, mode, parent-directory traversal, and privilege.
7
Can dependencies be reached?
Check resolution, route, listener, protocol, credentials, and application health.
8
Is capacity available?
Review disk, inode, memory, and process constraints before assuming code failure.
9
What is the smallest reversible correction?
Prefer a targeted change with verification and rollback over broad deletion or reconfiguration.
2
Incident exercise
Investigate a simulated failed web service
01
Confirm service and process state
Do not begin by reinstalling or deleting files.
systemctl status training-web
ps aux | grep training-web
02
Read the relevant journal
The log points to a configuration permission problem.
journalctl -u training-web -n 20
03
Inspect the configuration path
Check every directory component and the file itself.
namei -l /etc/training-web/app.conf
stat /etc/training-web/app.conf
04
Correct only the group access
Grant the service group read access without opening the file to everyone.
sudo chgrp webops /etc/training-web/app.conf
sudo chmod 640 /etc/training-web/app.conf
05
Restart and verify at multiple layers
Confirm unit state, listener, and application response.
sudo systemctl restart training-web
systemctl status training-web && ss -tulpn | grep :8080
curl http://localhost:8080/health
Knowledge check
Which troubleshooting action is usually the best first step?
Lesson 14 - Capstone
Provision, secure, operate, investigate, and back up a Linux service
The capstone combines filesystem work, identity, permissions, packages, services, logs, networking, processes, scripting, and archives. Complete it from the requirements and collect evidence for every claim.
Translate requirements into commandsApply least privilegeVerify behaviorPreserve evidence
1
Capstone scenario
Operations handoff for a small training application
Training Application Host
Prepare the virtual host for a web application operated by a dedicated service identity.
Create group webops and user trainapp with a home directory.
Create /srv/trainapp, assign owner trainapp and group webops, and apply mode 750.
Create /srv/trainapp/index.html and a protected configuration file readable by the owner and group only.
Install nginx, start and enable it, then inspect its package, process, service, log, and listener evidence.
Create ~/labs/linux/verify-trainapp.sh that prints identity, service state, listener state, and an HTTP health response.
Run the script and save its output to verification.txt.
Create trainapp-backup.tar.gz containing the application directory and verification report.
List the archive contents and retain the archive for grading.
2
Suggested evidence commands
Completion requires both state and behavior
ID
Identity
id trainapp getent group webops
FS
Filesystem
namei -l /srv/trainapp/index.html stat /srv/trainapp
SVC
Service
systemctl status nginx journalctl -u nginx -n 10
NET
Behavior
ss -tulpn | grep :80 curl http://localhost
3
Official references for a real environment
Use primary documentation when moving beyond the simulator
Kernel and C library interfaces underlying many Linux operations.
System interfaces
Transition to a real host carefully
Read every command, use a disposable lab system, protect credentials, verify backups, and treat recursive deletion, ownership changes, firewall changes, package removal, and storage operations as potentially destructive.
Knowledge check
Which capstone approach demonstrates sound administration?
Virtual File Editor
Edit a file in the simulated Linux filesystem.
Linux Command Sheet
Common forms supported by this teaching simulator.