Linux
Linux Troubleshooting Cheat Sheet
The commands to find out what is wrong on a Linux server: disk, memory, services, logs, ports, permissions, SSH and SELinux, on one printable page.
Updated November 1, 2026 · Applies to Ubuntu · Debian · RHEL / Rocky / AlmaLinux · systemd
Disk full
df -h # space per filesystemdf -i # inodes (many small files)sudo du -xh --max-depth=1 / | sort -h # biggest directoriessudo find / -xdev -type f -size +500M # big filessudo lsof +L1 # deleted, still opensudo journalctl --vacuum-size=500M # shrink the journalsudo truncate -s 0 /var/log/app.log # empty an open logGuide: No space left on device
Memory & processes
free -h # RAM and swapps aux --sort=-%mem | head # top memory usersps aux --sort=-%cpu | head # top CPU usersuptime # load averagesudo journalctl -k | grep -i 'out of memory' # OOM killskill PID # ask to stop (SIGTERM)kill -9 PID # force (SIGKILL)Services
systemctl status nginx # state + last log linessystemctl --failed # everything that failedsudo systemctl restart nginxsudo systemctl enable --now nginx # start + at bootsudo systemctl disable --now apache2 # stop + not at bootsystemctl status 812 # which unit owns a PIDLogs
sudo journalctl -u nginx -n 50 --no-pager # last 50 linessudo journalctl -u nginx -f # followsudo journalctl -xeu nginx # after a failed startsudo journalctl -p err -b # errors since bootsudo tail -f /var/log/nginx/error.log| Debian / Ubuntu | RHEL / Rocky / Alma | |
|---|---|---|
| System log | /var/log/syslog |
/var/log/messages |
| Logins, sudo, SSH | /var/log/auth.log |
/var/log/secure |
Ports & network
sudo ss -tlnp # listening TCP + processsudo ss -tlnp | grep ':80 ' # who has port 80?sudo lsof -i :80 -sTCP:LISTENcurl -I http://localhost # does the service answer?nc -zv db.internal 5432 # can I reach that port?ip -br a # addressesip r # routesgetent hosts example.com # name resolutionGuides: Address already in use · Nginx 502
Firewall
sudo ufw status verbose # Ubuntusudo firewall-cmd --list-all # RHEL familysudo firewall-cmd --permanent --add-service=httpsudo firewall-cmd --reloadPermissions
ls -l file ; ls -ld dir # mode, owner, groupnamei -l /var/www/html/index.html # every directory on the pathid deploy # user's groupssudo -l # what may I run with sudo?chmod u+x script.sh # make it executablesudo chown -R www-data: /var/www/app # user nginx: on RHELfindmnt -no OPTIONS --target /tmp # noexec?Guide: Permission denied running a script
SSH
ssh -v user@server # what the client triessudo journalctl -u ssh -n 30 # server side (sshd on RHEL)chmod 700 ~/.sshchmod 600 ~/.ssh/authorized_keys ~/.ssh/id_ed25519sudo sshd -t && sudo systemctl reload ssh # check config, reloadGuide: Permission denied (publickey)
SELinux (RHEL family)
getenforce # Enforcing / Permissivesudo ausearch -m avc -ts recent # recent denialsgetsebool -a | grep httpd # web server booleanssudo setsebool -P httpd_can_network_connect 1sudo restorecon -Rv /var/www/html # reset file labelsWarning
Don’t fix SELinux problems with setenforce 0. Find the denial and allow only that.