โ† Operating System Basics: From Zero to Hero
Level 3 ยท Hero: Power Moves

Hero Mission: Build a System Report

Lesson 14 of 14 ยท โฑ 20 min

You made it to the last lesson! You started at Zero, explored inside Linux, and now you're ready to be a Hero. ๐ŸŽ‰

Your path from Zero to Explorer to Hero.

๐Ÿ The mission: a system report

Your mission is to write one script that reports the most important facts about your own computer, using commands you already know.

The report script runs commands for the name, OS, kernel, uptime, CPU, memory, disk and busiest processes, then saves them to a file.

Step 1: plan

What to show Command you learned
Computer name hostname
Operating system cat /etc/os-release
Kernel version uname -r
How long it's been awake uptime -p
CPU cores nproc
Memory free -h
Disk space df -h /
Busiest programs ps aux --sort=-%cpu

Step 2: write the script

cd ~/MagiLab
nano sysreport.sh

Type this carefully:

#!/bin/bash
# Magi's System Report
echo "=== System report for $(hostname) ==="
echo "Made on: $(date)"
echo
echo "Operating system: $(. /etc/os-release && echo $PRETTY_NAME)"
echo "Kernel:           $(uname -r)"
echo "Awake for:        $(uptime -p)"
echo "CPU cores:        $(nproc)"
echo
echo "--- Memory ---"
free -h
echo
echo "--- Disk (main drive) ---"
df -h /
echo
echo "--- The 3 busiest programs ---"
ps aux --sort=-%cpu | head -4

Save (Ctrl + O, Enter) and exit (Ctrl + X).

Step 3: make it runnable and run it

chmod +x sysreport.sh
./sysreport.sh

Step 4: save it to a file

./sysreport.sh > report.txt
cat report.txt
ls -l report.txt

๐ŸŽ‰ You wrote a real program that asks the OS for facts about the hardware and the processes, and writes them to a file: almost every idea in this course in one script!

Your four hero quests

๐Ÿ” Quest 1: the process detective

Run top. Which are the three busiest programs? Which one uses the most memory? (Press M, then P.)

๐Ÿ—๏ธ Quest 2: the folder architect

Build a project tree three levels deep with mkdir -p, add four files, and show it with ls -R.

๐Ÿ”’ Quest 3: the safety star

Make one file private with chmod 600, and prove it with ls -l. Then teach a family member one safe habit.

๐Ÿ“– Quest 4: the boot storyteller

Run systemd-analyze and uptime -p. Explain the boot story to a friend using the restaurant idea.

Teach it back

The best way to be sure you understand something is to teach it. Explain "What is an operating system?" to a friend in one minute, with no big words.

What's next?

  • ๐Ÿ“ Try Raspberry Pi OS on a Raspberry Pi and explore a real Linux computer.
  • ๐Ÿ Learn a programming language like Python to write bigger programs.
  • ๐ŸŒ Find out how computers talk to each other in a network.
  • ๐Ÿ” Learn how passwords and encryption keep secrets safe.

The Final Exam

Ten questions from the whole course. Get 8 or more right to earn your Operating System Hero badge. ๐Ÿ…

๐ŸŽฏ The final exam

1. What is an operating system?
2. Which command shows how many CPU cores you have?
3. Which command shows the programs that are running right now, live?
4. What does the | symbol (the pipe) do?
5. Which command makes a script runnable?
6. What happens to a file you delete with rm?
7. Which Linux folder holds a file for each device?
8. In -rw-r--r--, which permission does the owner have?
9. What does the scheduler do?
10. Which password habit is best?