System Monitoring & Logs
After the last section taught you how to archive data for the long term, this one teaches you how to listen to the machine itself. Every Linux server has two things to say: how it is doing right now (memory, load, uptime) and what it has been doing (logs). This section covers both.
These commands answer the questions that come up whenever something feels slow, weird, or broken: Is the system out of memory? What was running when it crashed? What did the kernel log during boot? Where do I even find the logs?
Tools in This Section
| Page | What it does | Reach for it when |
|---|---|---|
| uptime | Shows how long the system has been running, and how busy it is | You want a 10-second pulse check: “has this box rebooted, and is it stressed?” |
| free | Reports memory and swap usage | You suspect the system is running out of RAM |
| uname | Prints kernel and system information | You need to know the OS, kernel, or architecture — in a script or a bug report |
| hostnamectl | Shows and changes the system hostname | You renamed a server or need to confirm its name |
| journalctl | Queries the systemd journal | Anything systemd-related misbehaves — services, boots, logins |
| dmesg | Prints the kernel ring buffer | Hardware, driver, or boot-time problems |
| /var/log tour | A guided tour of the classic log directories | You want to find a specific log file the old-fashioned way |
| vmstat | Reports memory, processes, paging, and CPU over time | You need a quick, scriptable health summary |
| iostat | Reports CPU and input/output (disk) statistics | Disk speed is suspicious and you want numbers |
topandhtopalready have their own pages in the Processes section — they are monitoring tools too, so this section links to them instead of duplicating them.
A Worked Example: “The Server Is Slow”
A realistic first move when a machine feels sluggish, using three tools from this section:
1. Is it up, and how long?
uptime
14:22:01 up 42 days, 3:17, 2 users, load average: 4.21, 3.87, 2.95
42 days since boot — so no surprise reboot. But load average above 3? Something is working the CPU hard.
2. Is it out of memory?
free -h
total used free shared buff/cache available
Mem: 15Gi 9.8Gi 1.2Gi 210Mi 4.1Gi 4.9Gi
Swap: 2.0Gi 312Mi 1.7Gi
available is 4.9 GiB — memory is fine. (Swap usage is small and old.)
3. What does the log say?
journalctl -p err -b --no-pager | tail -20
-p err filters to errors only, -b means “since this boot”. The last lines show a service failing to start repeatedly — the real culprit.
That flow — uptime → free → journalctl — is the fastest triage a sysadmin knows. For a live view of who is eating the CPU, jump to top or htop.
Why This Matters
- Diagnosis starts with observation. Half of troubleshooting is just reading the right numbers: memory, load, uptime.
- Logs are the machine’s memory. When something breaks at 3 AM, the logs are the only witness.
journalctlanddmesgare how you interview them. - You can’t fix what you can’t see. These commands turn vague “it feels slow” into concrete, fixable facts.
Next Up
Once you can read the machine’s vitals, the next section is Git & GitHub — version control for your code and this very wiki’s content.