Disclaimer: All scripts and examples are for educational use. Never run unverified code from unknown sources. The terminal executes exactly what you write — even your mistakes.
Why the Terminal Still Matters
Most people fear the terminal because it doesn’t smile back.
But here’s the secret: it listens better than any assistant ever made.
When you learn to talk to it, it doesn’t just execute — it obeys with precision.
Bash scripting is the language of automation, control, and curiosity.
The Script that Speaks
Let’s make Ubuntu speak when you log in:
#!/bin/bash
user=$(whoami)
hour=$(date +"%H")
if [ $hour -lt 12 ]; then
greeting="Good morning"
elif [ $hour -lt 18 ]; then
greeting="Good afternoon"
else
greeting="Good evening"
fi
echo "$greeting, $user! Welcome back to your terminal realm."
Save it as greet.sh, make it executable (chmod +x greet.sh),
and run it (./greet.sh).
You’ve just made a personal assistant with 9 lines of Bash.
Project: The System Guardian
Here’s something actually useful — a script to alert you when memory runs low.
#!/bin/bash
threshold=80
used=$(free | awk '/Mem/{printf("%.0f"), $3/$2*100}')
if [ $used -gt $threshold ]; then
echo "⚠️ Warning: Memory usage is ${used}%!"
notify-send "System Alert" "Memory usage is ${used}%!"
else
echo "✅ System OK — Memory at ${used}%"
fi
You can make it run every hour with:
crontab -e
and add:
0 * * * * /home/$USER/memory_guardian.sh
Now your system watches itself.
Experiment: The Logger of Shadows
Ask students to write a script that records every command they type:
#!/bin/bash
logfile="/home/$USER/command_log.txt"
echo "$(date): $@" >> "$logfile"
Then set an alias in .bashrc:
alias run='./logger.sh'
Now every time they use run ls or run cp, the command is recorded.
They’re not just coding — they’re understanding accountability.
Hidden Lesson: Bash = Logic + Trust
Bash teaches logical structure (if, loops, variables)
and discipline — because one missing fi can break an entire system.
In other words, it’s the perfect training ground for future developers.
In Summary
Teaching Bash isn’t about memorizing syntax.
It’s about showing that Ubuntu can listen, react, and even protect itself —
if you know how to speak its language.
