1. Start with host identity and uptime
Collect a baseline before troubleshooting. These commands are read-only and safe to run on a production host.
hostnamectl uname -a uptime who
2. Inspect CPU and memory
lscpu free -h top
free -h reports memory in human-readable units. On Linux, the available column is generally more useful than treating all cached memory as unavailable. In top, check load average, CPU states and processes sorted by resource use.
ps aux --sort=-%cpu | head -n 10 ps aux --sort=-%mem | head -n 10
3. Inspect disks and inodes
lsblk -f df -hT df -ih du -xhd1 /var 2>/dev/null | sort -h
df -hT shows filesystem capacity and type. df -ih checks inode exhaustion; a filesystem can fail to create files even when byte capacity remains.
4. Inspect processes and listening sockets
ps -eo pid,ppid,comm,%cpu,%mem --sort=-%cpu | head sudo ss -tulpn sudo lsof +L1 2>/dev/null | head
ss -tulpn lists listening TCP/UDP sockets and, with suitable privileges, owning processes. Treat exposed listeners as an inventory to review, not as proof that a service is vulnerable.
5. Build a concise diagnostic snapshot
{
echo "=== $(date -Is) ==="
hostnamectl
uptime
free -h
df -hT
sudo ss -tulpn
} 2>&1 | tee "$HOME/host-snapshot.txt"Keep snapshots in a controlled location. They can contain hostnames, usernames, IP addresses and service details; redact them before sharing publicly.
6. Troubleshooting sequence
- Check whether the symptom is CPU, memory, disk, network or application-specific.
- Compare current values with a known-good baseline.
- Identify the responsible process or service.
- Read relevant logs before restarting anything.
- Change one variable at a time and verify the result.
Key takeaways
- Prefer read-only inspection before remediation.
- Check both disk blocks and inodes.
- Correlate resource metrics with service logs.
- Protect diagnostic output because it may reveal infrastructure details.
References & further reading
Commands are examples for a representative Ubuntu/Linux environment. Review paths, versions, access requirements and maintenance impact before applying them to production systems.