Guides

Linux commands cheat sheet: files, processes, networking and more

The Linux commands a server admin uses daily — files, permissions, processes, networking, systemd, packages — grouped into one reference, linking the full guide for each.

Published ~10 min read

Short answer: the tables below group the Linux commands a server admin actually reaches for — files, processes, networking, permissions, packages — with the one-line version of what each does. Where a command has its own in-depth article (a full cheat sheet, or a specific error it throws), the table links to it.

Files and directories

CommandWhat it does
ls -laList files, including hidden ones, with permissions and sizes
cd pathChange directory
pwdPrint the current directory
cp -r src dstCopy, recursively for a directory
mv src dstMove or rename
rm -rf pathDelete, recursively and without confirmation — no undo
mkdir -p a/b/cCreate a directory, and any missing parent directories
touch fileCreate an empty file, or update its modified time
ln -s target linkCreate a symbolic link
find /path -name '*.log'Search for files by name, recursively
df -hDisk space free, per mounted filesystem, in human-readable units
du -sh pathTotal size of a directory

For finding what is filling a disk rather than just how full it is, see checking disk usage on Linux.

Permissions and ownership

CommandWhat it does
chmod 755 fileSet exact permissions by octal mode
chmod +x fileAdd execute, leaving read/write as they were
chown user:group fileChange the owning user and group
ls -l fileShow a file's current mode and owner

The full reference — octal vs symbolic mode, recursive chmod without breaking directories, and why 777 is almost never the fix — is in the chmod command guide.

Processes

CommandWhat it does
ps auxList every running process
top / htopLive, updating view of CPU and memory per process
kill PIDAsk a process to stop (SIGTERM)
kill -9 PIDForce-kill a process (SIGKILL, no cleanup)
pkill nameKill by process name instead of PID
nohup cmd &Run a command that survives the terminal closing

What every column in ps aux actually means is in ps aux explained.

Networking

CommandWhat it does
ip -4 addr showShow IPv4 addresses on every interface
ip routeShow the routing table
ss -tlnpList listening TCP ports and the process on each
ping hostTest reachability and round-trip time
curl -I urlFetch just the HTTP headers of a URL
dig domainQuery DNS records for a domain
nc -zv host portTest whether a single TCP port is open

More on ss, lsof and the other ways to check what is listening in checking open ports on Linux.

Setting an address so it stops changing on reboot is covered in static IP addresses, and clearing a stale DNS answer in flushing the DNS cache.

Services and logs (systemd)

CommandWhat it does
systemctl status nameIs a service running, and its recent log lines
systemctl restart nameRestart a service
systemctl enable nameStart a service automatically on boot
journalctl -u name -fFollow a service's logs live
journalctl -xeJump to the end of the system log with extra context

Installing software

DistributionInstallUpdate everything
Debian · Ubuntusudo apt install namesudo apt update && sudo apt upgrade
RHEL · Rocky · Almasudo dnf install namesudo dnf upgrade
Alpinesudo apk add namesudo apk update && sudo apk upgrade

A command not found right after installing often means the shell has not reloaded its command path yet (hash -r fixes that), or the package installs under a different binary name than expected:

Text processing

CommandWhat it does
cat filePrint a file's contents
less filePage through a file (q to quit)
grep text fileSearch for text inside a file
grep -r text dirSearch recursively through a directory
tail -f fileFollow a file as new lines are written to it
wc -l fileCount lines in a file
sed 's/old/new/g' fileReplace text (stream editor)

Archives and transfers

CommandWhat it does
tar -czvf out.tar.gz dir/Create a compressed archive
tar -xzvf out.tar.gzExtract one
scp file user@host:/pathCopy a file to a remote server over SSH
rsync -av src/ user@host:/path/Sync a directory, only transferring what changed

For an interactive session instead of a one-shot copy, see the sftp command.

More tar flags and what each one does in extracting tar.gz files on Linux.

Docker

Containers, images, Compose and cleanup have grown into their own reference: the Docker commands cheat sheet.

The one command that stops everyone

Sooner or later something opens vim — a git commit, crontab -e, a minimal server image with no nano installed — and the hardest part is getting back out:

Esc then :wq saves and quits; :q! quits and discards changes. The full table of exit commands, and why vim gets stuck in the first place, is in how to exit vim.

SSH, the entry point to all of the above

Every command on this page assumes you can already get into the server — start with generating an SSH key if you have not yet.

For the order to run these in on a brand-new server — create a user, lock down SSH, set up a firewall — see initial server setup.

Frequently asked

What is the most important Linux command for a beginner to learn first?

cd and ls — moving around and seeing what is there — followed by cat or less to read a file and sudo for anything that needs elevated permissions. Everything else builds on being able to navigate and read first.

How do I see what is using CPU or memory on a Linux server?

top or htop for a live, updating view; ps aux for a one-time snapshot. htop is easier to read but is not always preinstalled — apt install htop or dnf install htop adds it.

How do I find a file when I don't know which directory it's in?

find / -name 'filename' searches recursively from the root; locate filename is faster if the locate database is installed and up to date (updatedb refreshes it), but will not find anything created since the last update.

What is the difference between kill and kill -9?

kill PID sends SIGTERM, asking the process to shut down cleanly and save its state. kill -9 PID sends SIGKILL, which the process cannot ignore or clean up after — use it only once a plain kill has failed.

Related articles

All guides