Disk and memory
| Command | What it shows |
|---|---|
df -h | Free and used space on each disk |
du -sh /var/www/* | Size of each folder |
free -h | Memory and swap usage |
lsblk | Disks and partitions |
Processes and load
| Command | What it does |
|---|---|
top or htop | Live view of CPU, memory and processes |
uptime | Load average for 1, 5 and 15 minutes |
ps aux --sort=-%mem | Processes sorted by memory use |
kill PID | Ask a process to stop |
Services (systemd)
| Command | What it does |
|---|---|
systemctl status nginx | Is the service running, and its latest log lines |
systemctl restart nginx | Restart a service |
systemctl enable nginx | Start it automatically at boot |
systemctl --failed | List services that failed |
Logs
| Command | What it does |
|---|---|
journalctl -u nginx -n 100 | Last 100 log lines of a service |
journalctl -f | Follow the system log live |
tail -f /var/log/nginx/error.log | Follow a log file live |
Network
| Command | What it does |
|---|---|
ip a | IP addresses of the server |
ss -tulpn | Which ports are listening, and by which program |
ping example.com | Is a host reachable, and how fast |
dig example.com A | Ask DNS for a record |
curl -I https://example.com | Fetch only the response headers |
Files and permissions
| Command | What it does |
|---|---|
ls -lah | List files with sizes, owners and permissions |
chown -R www-data:www-data dir | Change the owner of a folder |
chmod 640 file | Set file permissions |
find /var/www -mtime -2 -type f | Files changed in the last two days |
tar -czf backup.tar.gz dir | Compress a folder into an archive |
Read a command twice before running it as root, especially anything with rm -r, chmod -R or chown -R.