Mission 4 of 5
System Monitoring and Performance
Collect a small health report from memory, processes, uptime, and logs.
Observe memory, uptime, processes, logs, and repeated command output.
Mental model
Understand what is happening
Monitoring is usually read-only.
top, watch, and less-like tools have exit keys.
Ctrl+C stops watch.
Guided lab
Work through the mission
Memory and uptime
Shows memory, uptime, and short virtual memory stats.
free -h
uptime
vmstat 1 2Process snapshots
Shows a non-interactive top snapshot and memory-heavy processes.
top -b -n 1 | head -20
ps aux --sort=-%mem | head -10Logs and watch
Reads recent logs only when systemd is running, then starts a repeating clock. This handles non-systemd distributions and WSL environments where systemd is disabled. Stop watch with Ctrl+C.
if command -v journalctl >/dev/null && [ "$(ps -p 1 -o comm=)" = systemd ]; then
journalctl -n 20 --no-pager
else
echo "systemd journal is not available in this environment"
fi
watch -n 2 dateCheckpoint
Verify the mission
The report captures a readable snapshot without changing the system.
Try it yourself
One step without a recipe
Use ps to find the top memory process. Run watch date and stop it with Ctrl+C.
Need a hint?
When you're stuck in `top` or `watch` and the terminal seems frozen, press `q` for top and Ctrl+C for watch. Knowing how to exit a tool is as important as knowing how to run it.
Explain it back
Before you move on
- How do you stop watch?
- Which command shows memory usage?