← all cheat sheets
OPERATOR REFERENCE · LINUX SERVER ADMIN

Linux Server Commands
Files · Users · Processes · Services · Network · Storage

the day-to-day sysadmin toolkit — one page, systemd-era, distro-neutral where it can be
Scope note: commands target modern systemd-based distros (Ubuntu/Debian, RHEL/Rocky/Alma, Fedora, SUSE). Package manager, firewall, and log paths differ by family — those are called out. Older SysV/init or minimal containers may lack systemctl, ip, or journalctlVERIFY against your box. Anything destructive is flagged; read before you paste as root.
INSPECT · what's the state?
change
ACT · config / service / fix
confirm
VERIFY · did it take?
01 First 60 Seconds on a New Box
ID

Who & Where

whoami ; id hostnamectl uptime
Identity, privileges, hostname/OS/kernel, and how long it's been up (a recent reboot is often the "what changed").
OS

Distro & Kernel

cat /etc/os-release uname -a arch
/etc/os-release tells you which package manager and paths apply before you run anything family-specific.
HW

Resources at a Glance

nproc ; free -h df -h ; lsblk top -bn1 | head -20
CPU count, memory, disk usage, block devices — the shape of the machine in four commands.
SVC

What's Running / Broken

systemctl list-units --failed systemctl list-units --type=service --state=running ss -tulpn
--failed first — the fastest read of what's already broken. ss -tulpn shows listening ports + owning process.
02 Files, Directories & Navigation
TaskCommandNotes
List detailed / hiddenls -lahLong, human sizes, includes dotfiles
Tree of dir sizesdu -sh * | sort -hFind what's eating space in the current dir
Disk freedf -hCheck per-mount; a full / or /var breaks logging & installs silently
Copy / move / removecp -a src dst · mv a b · rm -i f-a preserves perms/links; -i prompts before delete
Make dirs / empty filemkdir -p a/b/c · touch f-p creates parents as needed
Find by namefind / -name 'nginx.conf' 2>/dev/nullRedirect stderr to hide permission-denied noise
Find by size / agefind /var/log -type f -size +100M -mtime +30Big, old files — classic disk-cleanup hunt
Symlinkln -s /real/path /link-s = symbolic; without it you get a hard link
Where is a binarywhich cmd · type cmd · command -v cmdResolve what actually runs from your PATH
Archive / compresstar czf a.tgz dir/ · tar xzf a.tgzcreate/extract, gzip, file; use J for xz, j for bzip2
03 Viewing & Searching Text
CAT

Read & Page

less +F /var/log/syslog # tail-follow head -n 50 file ; tail -n 50 file tail -f /var/log/nginx/access.log
less beats cat for big files; tail -f follows a live log. In less, Shift+F follows, Ctrl+C stops.
GRP

grep

grep -rin 'error' /var/log/ grep -v '^#' config | grep -v '^$' journalctl -u nginx | grep -i fail
-recursive -ignore-case -n line numbers -v invert. The two--v trick strips comments & blank lines from a config.
AWK

awk / sed / cut

awk '{print $1}' access.log | sort | uniq -c sed -n '10,20p' file cut -d: -f1 /etc/passwd
Column extraction, ranged printing, delimiter splitting. sort | uniq -c | sort -rn = a top-N frequency count of anything.
04 Users, Groups & Permissions
USR

User & Group Management

useradd -m -s /bin/bash alice passwd alice usermod -aG sudo alice # add to group userdel -r alice # -r removes home groupadd devs ; groups alice
-aG is critical — append to groups; -G alone replaces all secondary groups and can lock a user out of sudo.
On RHEL the sudo group is wheel, on Debian/Ubuntu it's sudo. VERIFY before assuming.
PRM

Permissions & Ownership

chmod 640 file # rw-r----- chmod -R u+rwX,go-w dir chown -R alice:devs /srv/app umask # default mask
Octal: 4=r 2=w 1=x, per owner/group/other. Capital X sets execute only on dirs and already-executable files — safe for recursive use.
SUD

sudo & Privilege

sudo -l # what can I run? sudo -i # root login shell visudo # edit safely sudo -u www-data cmd # run as another user
Always edit sudoers with visudo — it syntax-checks before saving, so a typo can't lock everyone out of root.
SPC

Special Bits & ACLs

find / -perm -4000 2>/dev/null # SUID chmod +t /shared # sticky bit getfacl file ; setfacl -m u:bob:rw file
SUID/SGID run as the file owner — audit them. Sticky bit on a shared dir stops users deleting each other's files. ACLs give finer grants than owner/group/other.
05 Processes & Resource Monitoring
TaskCommandNotes
Live process viewtop · htophtop (if installed) is interactive — scroll, filter, kill by F-keys
Snapshot all processesps aux --sort=-%cpu | headSort by CPU or -%mem to find the hog
Process treepstree -pShows parent/child lineage with PIDs
Find a processpgrep -a nginx · pidof sshdpgrep -a shows the full command line
Signal / killkill -TERM PID · kill -9 PIDTry TERM (graceful) first; -9 (KILL) is last resort — no cleanup
Kill by namepkill -f pattern · killall proc-f matches the whole command line, not just the name
What's using a file/portlsof -i :443 · fuser -v /mnt/dataFind the process holding a port or a busy mountpoint
Memory pressurefree -h · vmstat 1Watch si/so (swap in/out) in vmstat — sustained swap = real pressure
Disk I/Oiostat -x 1 · iotopHigh %util/await = disk bound, not necessarily throughput
Load over timeuptime · sar -qLoad avg vs core count; sar gives history if sysstat is enabled
Background & detach: cmd & backgrounds it, jobs/fg/bg manage them, nohup cmd & or tmux/screen survive a disconnect. For long jobs on SSH, always use tmux/screen.
06 Services & systemd
SVC

systemctl — Service Control

systemctl status nginx systemctl start|stop|restart nginx systemctl reload nginx # re-read config, no drop systemctl enable --now nginx # boot + start now systemctl disable nginx
reload re-reads config without dropping connections where the service supports it; restart fully bounces it. enable = start at boot, separate from running now.
LOG

journalctl — Logs

journalctl -u nginx -e # unit, jump to end journalctl -u nginx -f # follow live journalctl -b # this boot journalctl -p err -b # errors only journalctl --since '1 hour ago'
-u filters to one unit, -b -1 is the previous boot (useful after a crash), -p filters by priority. --disk-usage / --vacuum-time=7d to manage log size.
UNI

Units & Config

systemctl list-units --failed systemctl cat nginx # show unit file systemctl edit nginx # override drop-in systemctl daemon-reload # after editing units
Edit with systemctl edit (creates a drop-in override) rather than hand-editing vendor unit files that a package update will overwrite. Always daemon-reload after changing unit files.
TMR

Timers & Boot

systemctl list-timers systemd-analyze blame # slow boot units systemctl get-default # target/runlevel systemctl reboot | poweroff
systemd timers are the modern cron replacement. systemd-analyze blame ranks what's slowing boot — faster than guessing which service to disable.
07 Networking
TaskCommandNotes
Show interfaces / IPsip addr · ip -br a-br = brief one-line-per-interface; ifconfig is deprecated
Routing tableip route · ip r get 8.8.8.8get shows which route/interface a destination actually uses
Listening ports + PIDss -tulpnModern netstat; -l listening -p process -n numeric
Test a portnc -zv host 443 · curl -v host:443TCP reachability without the app protocol succeeding
DNS lookupdig host +short · resolvectl query hostdig @8.8.8.8 host bypasses the local resolver to isolate the fault
Reachability / pathping host · mtr host · traceroute hostmtr = continuous ping-per-hop, best for intermittent loss
HTTP debugcurl -Iv https://host · wget -qO- url-I headers only, -v shows TLS + redirects
ARP / neighborsip neighL2 neighbor table on the local segment
NetworkManagernmcli dev status · nmcli con up NAMEOn NM-managed hosts, prefer nmcli over hand-editing configs
Capture packetstcpdump -ni eth0 port 443 -w cap.pcap-n no DNS, -w writes a pcap for Wireshark
08 Firewall — Know Which One Is Active
UFW

ufw (Ubuntu/Debian)

ufw status verbose ufw allow 22/tcp ufw allow from 10.0.0.0/8 to any port 5432 ufw enable ; ufw delete allow 80
Simplest frontend. Allow SSH before you enable or you lock yourself out of a remote box.
Enabling a firewall over SSH without allowing 22 first = instant lockout. Test on console access when you can.
FWD

firewalld (RHEL/Rocky)

firewall-cmd --state firewall-cmd --list-all firewall-cmd --add-service=https --permanent firewall-cmd --reload
Zone-based. --permanent writes config but doesn't apply until --reload — a very common gotcha.
NFT

nftables / iptables

nft list ruleset iptables -L -n -v --line-numbers iptables -S
The low-level layer ufw/firewalld drive. nftables is the modern replacement for iptables — one may be a compat shim over the other. VERIFY which manages rules.
09 Storage, Disks & Mounts
TaskCommandNotes
Block devices & mountslsblk -f · blkid-f shows filesystem + UUID + mountpoint
Disk usage / freedf -hT · du -sh /var/*-T also shows filesystem type
Find inode exhaustiondf -iDisk "full" with free space? Out of inodes — often millions of tiny files
Mount / unmountmount /dev/sdb1 /mnt · umount /mntumount -l lazy-unmounts a busy mount
Persistent mountsvi /etc/fstab ; mount -amount -a tests fstab without a reboot — do this before rebooting
Format filesystemmkfs.ext4 /dev/sdb1destroys data — triple-check the device name
LVM overviewpvs · vgs · lvsPhysical → volume group → logical volume; lvextend -r grows LV + FS
Disk healthsmartctl -a /dev/sdaSMART attributes — reallocated sectors / pending = failing drive
Swapswapon --show · free -hConfirm swap exists & size before diagnosing memory pressure
Wrong-device mistakes here are unrecoverable. Confirm with lsblk immediately before any mkfs, dd, or partition edit — device letters (sda/sdb) can shift between boots.
10 Package Management — By Distro Family
TaskDebian/Ubuntu (apt)RHEL/Rocky/Fedora (dnf)SUSE (zypper)
Update indexapt updatednf check-updatezypper refresh
Upgrade allapt upgradednf upgradezypper update
Installapt install nginxdnf install nginxzypper install nginx
Removeapt remove nginxdnf remove nginxzypper remove nginx
Searchapt search termdnf search termzypper search term
What provides a filedpkg -S /path · apt-file searchdnf provides /pathzypper what-provides
List installeddpkg -l · apt list --installedrpm -qa · dnf list installedzypper se -i
Package of a commanddpkg -S $(which cmd)rpm -qf $(which cmd)rpm -qf $(which cmd)
Also common: snap and flatpak for sandboxed apps, pip/npm for language packages — keep OS packages and language packages mentally separate. apt full-upgrade / dnf handle dependency changes that plain upgrade won't.
11 SSH, Transfers & Remote Ops
KEY

Keys & Connect

ssh-keygen -t ed25519 -C "you@host" ssh-copy-id user@host ssh -i ~/.ssh/id_ed25519 user@host ssh -J jump user@internal # jump host
Ed25519 keys over passwords. -J proxies through a bastion. Config lives in ~/.ssh/config for reusable host aliases.
CPY

Copy Files

scp file user@host:/path/ rsync -avz --progress src/ user@host:/dst/ rsync -avzn src/ dst/ # -n dry run
rsync beats scp for large/repeat transfers — only sends deltas, resumes, and -n previews first. Mind the trailing slash on source dirs.
HRD

Harden sshd

# /etc/ssh/sshd_config PermitRootLogin no PasswordAuthentication no sshd -t # test config systemctl reload sshd
Key-only auth, no direct root. Always sshd -t to validate config and keep your current session open until a new one connects.
Don't close your only session after editing sshd_config — open a second connection to confirm you can still log in.
12 Scheduling, Env & Shell
CRN

cron & Timers

crontab -e ; crontab -l # min hr dom mon dow cmd 0 2 * * * /usr/local/bin/backup.sh systemctl list-timers # systemd alt
Fields: minute, hour, day-of-month, month, day-of-week. Use full paths and redirect output (>>log 2>&1) — cron has a minimal environment and won't find your PATH.
ENV

Environment & History

env · printenv PATH export VAR=value history · !! · !$ alias ll='ls -lah'
Persist exports/aliases in ~/.bashrc (interactive) or /etc/environment (system-wide). !! reruns last command, !$ is its last argument.
RED

Redirection & Pipes

cmd > out.txt 2>&1 # stdout+stderr cmd | tee log.txt # see + save cmd1 && cmd2 || echo fail diff <(cmd1) <(cmd2) # process sub
2>&1 merges stderr into stdout, tee writes and displays, &&/|| chain on success/failure.
TMX

Persistent Sessions

tmux new -s work tmux attach -t work # reconnect # Ctrl-b d = detach screen -S work ; screen -r
Run long jobs (upgrades, migrations, restores) inside tmux/screen so a dropped SSH connection doesn't kill them mid-run.
13 Server Troubleshooting — Symptom → First Check
SymptomFirst Checks
Service won't startsystemctl status svc ; journalctl -u svc -e
"No space left on device"df -h ; df -i ; du -sh /var/* ; journalctl --disk-usage
Load average very hightop ; ps aux --sort=-%cpu ; uptime ; iostat -x 1
Out of memory / OOM killsfree -h ; dmesg -T | grep -i oom ; journalctl -k
Port not reachabless -tulpn ; firewall status ; curl -v localhost:PORT
Can't resolve DNSresolvectl status ; dig @8.8.8.8 host ; cat /etc/resolv.conf
Slow disk / I/O waitiostat -x 1 ; iotop ; dmesg -T | tail (I/O errors)
Hardware / kernel faultsdmesg -T | tail -50 ; journalctl -k -b
Recent change / who did whatlast ; journalctl --since '2 hours ago' ; ls -lt /etc
Config edited but no effectsystemctl reload/restart svc ; check for a config test flag first
Method: reproduce → check the service's own status + logs → check the resource it depends on (disk, memory, network, a downstream service) → change one thing → verify under the same conditions. dmesg and journalctl answer most "what just happened" questions faster than guessing.