Real-Time Resource Monitoring
These tools give you a live view of what your system is doing right now.htop
A color-coded, interactive process viewer with easy sorting and filtering. Use arrow keys to navigate and
F9 to send signals to processes.glances
Shows CPU, memory, disk, network, and processes in a single terminal view. Supports remote monitoring via a web interface or API.
CPU and Memory Statistics
For scripting and deeper analysis, use these non-interactive tools that print structured output you can log or pipe to other commands.uptime represents the average number of processes waiting for CPU time over the last 1, 5, and 15 minutes. A load average consistently higher than your CPU core count indicates the system is under strain.
Disk I/O Monitoring
High disk I/O is a common cause of sluggish systems. These tools help you find what is causing it.iotop requires root privileges: run it with sudo iotop. Look at the DISK READ and DISK WRITE columns to identify the process generating the most I/O.Network Monitoring
ss -tuln is the modern replacement for netstat -tuln and is faster on systems with many connections. Use it to quickly see which ports your server is listening on.
Log File Locations
Linux services write logs to/var/log/. Knowing where to look saves time during an incident.
| Log file | Contents |
|---|---|
/var/log/syslog or /var/log/messages | General system activity |
/var/log/auth.log | Authentication and sudo events |
/var/log/kern.log | Kernel messages |
/var/log/dmesg | Boot-time hardware messages |
/var/log/apt/ | Package installation and removal |
/var/log/nginx/ | Web server access and error logs |
Viewing and Filtering Log Files
grep with -A and -B flags to show lines around a match: grep -i error -A 5 /var/log/syslog shows 5 lines of context after each error, which often reveals the cause.
journalctl: systemd Journal
systemd routes all service logs to a structured binary journal.journalctl is the tool for querying it.
- Priority levels
- Combining filters
The
-p flag accepts syslog priority levels: emerg, alert, crit, err, warning, notice, info, debug. Specifying a level shows that level and all higher-severity levels — so -p err shows errors, critical messages, alerts, and emergencies.logrotate: Managing Log Growth
Without rotation, log files grow until they fill your disk.logrotate handles this automatically on most distributions. To configure rotation for a custom application, create a file in /etc/logrotate.d/:
rotate 14— keep 14 rotated logs before deletingcompress/delaycompress— gzip old logs, but not the most recent rotationmissingok— don’t error if the log file is missingpostrotate— run a command after rotating (useful for telling the app to re-open its log file)