Cheat sheet

Linux — Essential commands

Linux field reference for system, processes, systemd, logs, storage, networking, DNS, firewall, accounts and SSH.

⌚ About 3 min read
View my favorites
LinuxBeginner to advanced8 sections · 32 reference points

Linux field reference for system, processes, systemd, logs, storage, networking, DNS, firewall, accounts and SSH.

System & load

Distribution
cat /etc/os-release

Identifies distribution/version before distro-specific commands.

Kernel
uname -a

Checks kernel, architecture and build.

Uptime & load
uptime

Load averages are roughly 1, 5 and 15 minutes.

Memory
free -h

Focus on available memory rather than free alone.

Processes

Top CPU
ps aux --sort=-%cpu | head -20

Lists top CPU consumers at capture time.

Top memory
ps aux --sort=-%mem | head -20

Correlate with RSS/VSZ and application behavior.

Interactive view
top

htop is convenient when installed; top is more universal.

Process tree
pstree -ap

Helps relate workers, parents and services.

systemd & logs

Service status
systemctl status nginx --no-pager

Shows state, PID and recent journal lines.

Failed units
systemctl --failed

Quick starting point after reboot.

Service journal
journalctl -u nginx --since '-2 hours' --no-pager

Targets a time window near the incident.

Boot errors
journalctl -b -p err..alert --no-pager

Filters errors from the current boot.

Storage & filesystems

Filesystem usage
df -hT

Adds filesystem type to capacity view.

Inodes
df -i

A filesystem can be full due to inode

Block devices
lsblk -f

Shows partitions, filesystems, UUIDs and mounts.

Large directories
du -xhd1 /var 2>/dev/null | sort -h

-x prevents crossing into other mounted filesystems.

Network

Addresses
ip -br addr

Compact interface/address view.

Routes
ip route

Checks default and specific routes.

Neighbors
ip neigh

Modern ARP/ND neighbor view.

Listening ports
ss -lntup

Maps sockets, ports and processes when permissions allow.

DNS & HTTP

Resolver status
resolvectl status

Shows per-interface DNS with systemd-resolved.

DNS lookup
dig +short exemple.fr

Simple lookup for A/AAAA/CNAME checks.

HTTP headers
curl -I https://exemple.fr

Checks status, redirects and headers without full body.

Verbose TLS
curl -vkI https://exemple.fr

-k disables validation; diagnostic only, not proof of valid TLS.

Firewall & network security

nftables
sudo nft list ruleset

Modern firewall view on many distributions.

UFW
sudo ufw status verbose

Common on Ubuntu when UFW is enabled.

firewalld
sudo firewall-cmd --list-all

Used on distributions running firewalld.

Connections
ss -ant state established

Quick view of established TCP connections.

Accounts, permissions & SSH

Identity
id utilisateur

Shows UID, GID and groups.

Path permissions
namei -l /var/www/html/index.php

Shows each path component and permissions.

SSH host keys
sudo ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub

Lets you compare the server host-key fingerprint.

Effective SSH config
sudo sshd -T | head -50

Shows effective configuration rather than only the main file.

Key points

  • Use sudo only when required.
  • du, find and recursive scans can generate significant I/O.
  • Before restarting critical services, capture status and logs.
  • Firewall commands depend on the distribution and active firewall stack.
← All cheat sheets
♡ 0