Thirty-one references to the commands you actually use on a Linux machine — what each one is for, the flags worth remembering, and the ways each of them catches people out. Every page is written to be read when you need it rather than end to end.
New to the terminal? Read Linux Command Line Basics first. It covers moving around, wildcards, quoting, pipes and redirection — the things every page below assumes you already have.
What are you trying to do?
| If you want to… | Read |
|---|---|
| Find the lines that match something | grep |
| Find files by name, size, age or owner | find |
| Change text in a file without opening it | sed |
| Work with columns in a stream of text | awk |
| Turn a log file into a count or a list | sort, uniq, cut and the rest |
| Run a command against every item in a list | xargs |
| Fix who can read or write a file | File permissions |
| Understand symlinks and hard links | ln |
| Pack or unpack an archive | tar |
| Choose between gzip, zstd and xz | Compression |
| Mount a disk so it survives a reboot | Disks and mounting |
| Write an image to a USB stick | dd |
| Add a user, or expire a password | User management |
| Give someone a narrow slice of root | sudo |
| Log into another machine, or tunnel a port | ssh |
| See what is running, and stop it | Processes |
| Find out what filled the disk | Disk space |
| Read what the system has been logging | journalctl |
| Find what is holding a port, a file or a mount | lsof and fuser |
| Work out why you cannot reach something | Networking basics |
| Set an address, or inspect a route | ip |
| Inspect a certificate, or what a server is serving | openssl |
| Copy only what changed | rsync |
| Fetch a file, or poke an API | curl and wget |
| Start, stop or inspect a service | systemctl |
| Schedule something the traditional way | cron |
| Schedule something the systemd way | systemd timers |
| Fix a clock, or a time zone | timedatectl |
| Install, remove or search for software | Package management |
| Stop losing the command you typed last week | Shell history |
| Edit a file in a terminal | vim and nano |
Searching and text processing
Text on Linux means almost everything — logs, configuration, source, the output of any command. These six are how you get at it.
- grep — find the lines that match
- find — locate files by name, size, age or ownership, and act on what you find
- sed — change text without opening an editor
- awk — for when the lines have columns
- sort, uniq, cut and the rest — the small tools that turn a log file into an answer
- xargs — turning a list into commands, safely, and where GNU parallel takes over
Files, disks and archives
- File Permissions — chmod, chown and umask
- ln — hard links and symbolic links, and why they are not variations on one idea
- tar — the three invocations worth memorising
- Compression — gzip, zstd, xz and bzip2, and which to use when
- Disks and Mounting — lsblk, mount and fstab
- dd — bootable USBs, disk images, and the command that will happily destroy the wrong drive
Users and access
- User Management — useradd, usermod, passwd and chage
- sudo — running commands as another user, narrowly
- ssh — remote access, keys and tunnels
Working out what is wrong
What is running, what filled the disk, what is holding something open, and what the machine has been trying to tell you.
- Processes — ps, top and htop
- Disk Space — df, du and ncdu, including the two cases where they appear to lie to you
- lsof and fuser — what has this port, what is keeping this mount busy, and where the deleted disk space went
- journalctl — filtering the systemd journal, and the setting that decides whether yesterday still exists
Networking and certificates
- Networking Basics — ip, ss, ping and dig, and the order to try them in
- ip — addresses, links and routes in depth, and why none of it survives a reboot
- openssl — the six things people actually need, including what a live server is really serving
Moving things around
- rsync — copy only what changed, and the trailing slash that changes everything
- curl and wget — talking to things vs taking things
Services, scheduling and software
- systemctl — start, stop and inspect services
- cron — scheduling, and the small number of ways it always fails
- systemd Timers — the replacement for cron, and when cron is still the right answer
- timedatectl — clocks, time zones, and why a schedule in local time is a trap
- Package Management — apt, dnf and pacman side by side
Living in the shell
- Shell History — Ctrl+R, history expansion, and why your history keeps disappearing
- vim and nano — editing files in a terminal, starting with how to exit vim
Where to go next
These pages tell you how. Two other sections cover the rest: Learn explains why — what a process really is, how permissions are decided, what happens during boot — and Tools covers the modern replacements for several of the commands above, on the principle that you learn the classic and install the newer one.
