Commands

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 somethinggrep
Find files by name, size, age or ownerfind
Change text in a file without opening itsed
Work with columns in a stream of textawk
Turn a log file into a count or a listsort, uniq, cut and the rest
Run a command against every item in a listxargs
Fix who can read or write a fileFile permissions
Understand symlinks and hard linksln
Pack or unpack an archivetar
Choose between gzip, zstd and xzCompression
Mount a disk so it survives a rebootDisks and mounting
Write an image to a USB stickdd
Add a user, or expire a passwordUser management
Give someone a narrow slice of rootsudo
Log into another machine, or tunnel a portssh
See what is running, and stop itProcesses
Find out what filled the diskDisk space
Read what the system has been loggingjournalctl
Find what is holding a port, a file or a mountlsof and fuser
Work out why you cannot reach somethingNetworking basics
Set an address, or inspect a routeip
Inspect a certificate, or what a server is servingopenssl
Copy only what changedrsync
Fetch a file, or poke an APIcurl and wget
Start, stop or inspect a servicesystemctl
Schedule something the traditional waycron
Schedule something the systemd waysystemd timers
Fix a clock, or a time zonetimedatectl
Install, remove or search for softwarePackage management
Stop losing the command you typed last weekShell history
Edit a file in a terminalvim 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.