A compact operational reference for daily server work and first-response troubleshooting.
Cloud & infrastructureReferenceUpdated Aug 13, 2026linuxcommandscheatsheettroubleshooting
Use this page after you understand the commands. Copying an unfamiliar destructive or privileged command into production is not an operating procedure.
hostnamectl # system identityuptime # uptime and loadfree -h # memory and swapdf -hT # filesystem capacity and typedu -sh * 2>/dev/null | sort -h # size of entries hereps aux --sort=-%cpu | head # top CPU processessystemctl --failed # failed unitstimedatectl # clock, timezone, and time synclast reboot # recent reboot historydmesg --level=err,warn # current boot's kernel warnings
ls -lah # detailed listingfind /path -type f -name '*.log' # find by name and typeless file # inspect safelytail -F file # follow a rotating loggrep -Rin 'pattern' /path # recursive content searchcp -a source destination # preserve metadata when copyingrsync -a --dry-run src/ dest/ # preview synchronizationnamei -l /full/path/to/file # permissions on every path componentfile archive.tar.gz # detect file type from contentsha256sum file # calculate an integrity checksum
tar -czf backup.tar.gz directory/ # create a gzip-compressed archivetar -tzf backup.tar.gz # list archive contents before extractiontar -xzf backup.tar.gz # extract the archive herersync -aHAX --dry-run src/ dest/ # preview a metadata-preserving local copyscp file user@host:/tmp/ # copy one file over SSHsftp user@host # interactive transfer over SSH
Inspect an archive before extracting it as root. For full server copies, confirm filesystem, ACL, extended-attribute, and hard-link requirements before choosing rsync flags.
whoamiidsudo -lstat filechmod 640 filechown user:group filegetent passwd deploygetent group www-datagetent hosts example.comsudo -u deploy command # run one command as the service userumask # default permissions for new files
pgrep -af nginx # find matching PIDs and full commandsps -o pid,ppid,user,%cpu,%mem,etime,cmd -p PIDsudo lsof -p PID # files and sockets opened by a processnice -n 10 command # start with lower CPU scheduling priorityrenice 10 -p PID # adjust a running process prioritysystemctl list-timers --all # systemd timers and their next runscrontab -l # current user's cron jobssudo crontab -u deploy -l # another user's cron jobs
systemctl status SERVICE --no-pagersystemctl restart SERVICEsystemctl reload SERVICEsystemctl enable --now SERVICEjournalctl -u SERVICE -n 100 --no-pagerjournalctl -u SERVICE -fjournalctl --since '-30 min' -p warningsystemctl cat SERVICE # unit file plus drop-in configurationsystemctl show SERVICE -p User -p MainPID -p ExecStartjournalctl -b -u SERVICE # service logs from the current boot
ip -brief addressip routesudo ss -tulpndig +short example.com Anc -vz example.com 443curl -fsS http://127.0.0.1:3000/healthcurl -vI https://example.comsudo ufw status numberedresolvectl status # configured DNS resolversip route get 1.1.1.1 # route chosen for a destinationopenssl s_client -connect example.com:443 -servername example.com
For RHEL-family firewalls, inspect sudo firewall-cmd --list-all instead of UFW. A successful TCP connection does not prove the application is healthy; follow it with an HTTP or protocol-specific check.
sudo cp -a config config.bak.$(date +%Y%m%d%H%M%S)sudoedit configVALIDATOR -t # nginx -t, sshd -t, compose config --quietsudo systemctl reload SERVICEsystemctl status SERVICE --no-pager
Check before running a risky command
For rm, chmod, chown, firewall rules, database changes, and recursive operations: resolve the target, preview where possible, keep a recovery path, and know how to verify success.