System Health
Users, logs, services and the numbers that say whether a computer is healthy. Linux (and WSL) first, with the Mac's equivalents named.
Updated
People
- Users and Groups (Journeyman): Every person and many programs on a Linux computer have a user account with a number and a list of groups: whoami, id and groups show yours, /etc/passwd lists every account, adduser and usermod -aG add a person and a group, and a server runs each program as a user of its own.
Watching
- Reading System Logs (Journeyman): Programs on a Linux computer write down what happens in logs, the files in /var/log and systemd's journal; journalctl -u shows one service's lines, -f watches new ones arrive, and on a Mac log show and the Console app do the same job.
- Services: systemctl (Journeyman): A service is a program that runs in the background with no window and starts when the computer does; on Linux, systemd runs them, systemctl status shows whether one is running, and sudo systemctl start, stop, restart, enable and disable change it now or at every start-up.
- Is It Healthy? Memory, Load and Uptime (Journeyman): uptime says how long a computer has been running and how busy it is, which you compare with the number of CPUs nproc prints; free -h says how much memory is still available and df -h how much disk is left; and a short script puts them all on one screen.
Exercise: The Health Check
- Exercise: The Health Check (Journeyman): Finish a health check script for a book club's home server: read the disk, memory, load and failed services, warn about each problem, and exit with a code that says whether all is well, while a check script runs it on a pretend computer, job by job.