Voice Coach Mode π
Let the browser explain concepts while learners interact
Use the voice buttons when teaching live, or switch Voice On so the page explains what happened after animations, terminal steps, and quiz answers.
Note: most browsers require a learner click before audio starts. Voice quality depends on the browser and operating system voices.
Mission Brief: Teach the Server to Help Itself π€
The server is bored of repeated manual commands. Your job is to become a Linux Automation Cadet and give the server small scripts it can run again and again.
- Write commands in a file.
- Add a shebang:
#!/bin/bash. - Make the file executable using
chmod +x. - Run it using
./script_name.sh.
By the end, learners can read and create beginner shell scripts using variables, input, conditions, loops, and exit status.
Concept Cards: Shell Scripting Made Simple
π Recipe for Linux
A script is like a recipe. Each line is one instruction for the shell to follow.
Example: backup filesExample: check diskπ¦ Storage box
A variable stores a value so the script can reuse it later.
name="JP" echo "Hello $name"
π’ Speaker
echo prints text or variable values on screen.
echo "Welcome to shell scripting"
ποΈ Microphone
read takes input from the user and stores it in a variable.
read -p "Enter name: " name echo "Hello $name"
π¦ Decision gate
if lets a script choose what to do depending on a condition.
if [ "$user" = "root" ]; then echo "Admin user" else echo "Normal user" fi
π Repeat machine
for repeats commands for each item in a list.
for item in disk memory users do echo "Checking $item" done
β Result checker
$? stores whether the previous command succeeded. 0 usually means success. Non-zero usually means failure.
df -h if [ $? -eq 0 ]; then echo "Success" else echo "Failed" fi
π οΈ Why scripting matters
Automation is useful when the same task is done many times: checking disk space, collecting logs, backing up files, validating services, or generating reports.
| Manual work | Scripted work |
|---|---|
| Type commands every time. | Run one script whenever needed. |
| Easy to forget steps. | Same steps run consistently. |
| Hard to repeat for many servers. | Can be reused and scheduled. |
Animated Flow: What Happens When a Script Runs?
Click the button and watch the script travel from text file to command output.
Script file
check_disk.shShebang
#!/bin/bashBash reads lines
df -h runsDisk output appears
Command Playground: Predict, Run, Understand
Try the name box
Enter a name and see how a variable is reused inside echo.
Disk warning simulator
Set disk usage and let the script decide whether to warn you.
Loop through services
Click to simulate a loop checking common Linux services.
Success or failure?
Choose a command result and watch $? decide the next message.
Interactive Terminal Simulator
This does not change your computer. It simulates the training lab so learners can understand the sequence before running it on Linux.
$ Ready. Click a mission command below.
Main Lab: Create Your First Disk Check Script π§ͺ
Run these commands on Ubuntu, Rocky Linux, RHEL, or most Linux distributions with Bash available.
cat > check_disk.sh <<'EOF' #!/bin/bash df -h EOF chmod +x check_disk.sh ./check_disk.sh
./check_disk.sh? The current directory is usually not searched automatically for commands. ./ means βrun the script from this directory.βFilesystem Size Used Avail Use% Mounted on /dev/sda1 40G 18G 22G 45% / tmpfs 3.9G 0 3.9G 0% /dev/shm ...
The exact filesystem names and sizes will differ on every machine.
Script Evolution: From Tiny Script to Useful Automation
Beginners often understand single commands but struggle to combine them. This section shows the same script growing step-by-step.
Version 1: Basic disk check
#!/bin/bash df -h
Version 2: Add a heading
#!/bin/bash echo "Disk usage report:" df -h
Version 3: Save report to a file
#!/bin/bash df -h > disk_report.txt echo "Report saved to disk_report.txt"
Version 4: Check exit status
#!/bin/bash df -h > disk_report.txt if [ $? -eq 0 ]; then echo "Disk report created successfully." else echo "Disk report failed." fi
Version 5: Ask user before running
#!/bin/bash read -p "Do you want to check disk usage? yes/no: " answer if [ "$answer" = "yes" ]; then df -h else echo "Okay, skipping disk check." fi
Common Beginner Errors and Fixes π§―
| Error / Symptom | Likely Cause | Fix |
|---|---|---|
Permission denied | Script is not executable. | chmod +x check_disk.sh |
command not found | Wrong script path or missing ./. | ./check_disk.sh |
| Variable does not expand | Used single quotes around variable. | Use "Hello $name", not 'Hello $name'. |
[: missing `]' | Missing spaces inside test brackets. | Use [ "$x" -gt 10 ]. |
| Script uses wrong shell | Missing or incorrect shebang. | Add #!/bin/bash as the first line. |
Boss Lab: Server Health Checker π²
This final challenge combines echo, commands, simple structure, and automation thinking.
cat > health_check.sh <<'EOF' #!/bin/bash echo "==============================" echo " Simple Server Health Checker " echo "==============================" echo echo "Disk Usage:" df -h echo echo "Memory Usage:" free -h echo echo "Logged-in Users:" who echo echo "System Uptime:" uptime EOF chmod +x health_check.sh ./health_check.sh
- Which command checks disk usage?
- Which command checks memory?
- Which command shows logged-in users?
- How can we save this report to a file?
Knowledge Check Quiz π―
#!/bin/bash do?chmod +x script.sh do?0 usually mean?Trainer Notes: Make the Session Fun and Sticky
Ask this first
βWhich Linux task do you repeat often?β Then show how a script can turn that repeated task into one file.
Use mistakes deliberately
Run the script before chmod +x so learners see Permission denied, then fix it. This makes troubleshooting memorable.
Driver and navigator
One learner types, the other explains each command. Swap roles after the first script.
Take-home task
Ask learners to create my_report.sh that prints date, hostname, disk usage, memory usage, and uptime.