Book

The Linux Command Line: A Complete Introduction, 3rd Edition

What this book is

Shotts wrote the gentlest, most practical introduction to the Linux/Unix shell in print. The third edition (No Starch Press) walks an absolute beginner from "what's a terminal?" through navigating the filesystem, manipulating files, mastering text-processing tools, and writing real bash scripts — without ever assuming prior knowledge or skipping the basics.

It is a reference that earned its reputation by being honest about what newcomers struggle with. Each topic is short, hands-on, and immediately runnable. The book is structured as 36 numbered topics across four parts — start at the beginning if you're new; jump to any topic later as a lookup reference.

The shape of the book

The shape of the book

Executive summary

The book makes three claims that change how you work, even if you've used Linux before.

Newcomers treat the terminal like a command-search interface — type a command, get output, move on. Shotts reframes the shell as a composable expression language: pipes connect tools, redirection captures output, command substitution feeds the result of one command into another. The same building blocks scale from "list files modified today" to a 200-line backup script.

Most "Linux problems" reduce to four things

Permissions, environment variables, PATH resolution, and text formatting account for nearly every confusing error a beginner hits. Topics 9 (Permissions), 11 (The Environment), 5 (Working with Commands), and 21 (Formatting Output) are the four things to deeply understand. Everything else is application.

Shell scripting is real programming with weird syntax

The fourth part doesn't apologise for bash. Top-down design, control flow, parameters, troubleshooting — the same engineering discipline you'd bring to Python, applied to a language whose idioms are 50 years old. The result is scripts that survive in production, not the 20-line shell hacks most engineers write.

Who this is for

Topic index

Topic 1 — What Is the Shell?Terminal vs. shell vs. session. The first commands and what they actually do.Topic 2 — NavigationFilesystem hierarchy, pwd/cd/ls, absolute vs. relative paths.Topic 3 — Exploring the SystemFile types, file command, less, common system locations.Topic 4 — Manipulating Files and Directoriescp, mv, rm, mkdir, ln — and the wildcards that make them powerful.Topic 5 — Working with Commandstype, which, help, man — figuring out what a command is and how PATH resolves it.Topic 6 — RedirectionThe pipe model: stdin, stdout, stderr, and the operators that combine them.Topic 7 — Seeing the World as the Shell Sees ItExpansion, quoting, escaping — why your command sometimes does something you didn't expect.Topic 8 — Advanced Keyboard TricksHistory, bang-bang, line editing, completion — the productivity layer.Topic 9 — PermissionsUser/group/other, rwx, chmod, chown, suid — the single most-asked-about Linux topic.Topic 10 — Processesps, jobs, kill, nice, signals — how the kernel sees what your shell is doing.Topic 11 — The EnvironmentVariables, export, dotfiles, login vs. non-login shells — the configuration model.Topic 12 — A Gentle Introduction to vi(m)Enough vi to survive when nano isn't installed. Modes, motions, the minimal command set.Topic 13 — Customizing the PromptPS1 escape codes, colour, info-dense prompts that don't slow you down.Topic 14 — Package Managementapt vs. dnf vs. pacman — the model is the same, the verbs differ.Topic 15 — Storage MediaBlock devices, mounting, partitioning, filesystems, fsck — the layer most developers ignore.Topic 16 — Networkingping, traceroute, ssh, scp, rsync, wget — the daily networking toolkit.Topic 17 — Searching for Fileslocate vs. find. Why find is hard, and the recipes that pay off.Topic 18 — Archiving and Backuptar, gzip, rsync — what to use when, plus the 3-2-1 rule for personal data.Topic 19 — Regular ExpressionsThe pattern language under grep, sed, awk, vim, less, and most editors.Topic 20 — Text ProcessingThe book's biggest topic. cat, sort, uniq, cut, paste, join, tr, sed, aspell — the toolkit Unix is famous for.Topic 21 — Formatting Outputfmt, pr, printf, groff — the legacy print/typesetting layer that still matters for reports.Topic 22 — Printinglpr, lpq, lpstat — the line printer subsystem most people forgot still exists.Topic 23 — Compiling Programsconfigure, make, make install — what the magic incantation actually does.Topic 24 — Writing Your First ScriptShebang, executable permissions, PATH, what makes a script reusable.Topic 25 — Starting a ProjectDocument-generation script as the running example. Scope, structure, decomposition.Topic 26 — Top-Down DesignStepwise refinement — writing a script outside-in via empty functions you fill later.Topic 27 — Flow Control: Branching with ifif/then/else, test, [[ ]], (( )), the comparison operators bash actually uses.Topic 28 — Reading Keyboard Inputread, validation, secure input — turning a script into an interactive tool.Topic 29 — Flow Control: Looping with while/untilwhile, until, breaking out, reading files line-by-line correctly.Topic 30 — Troubleshootingset -e, set -x, defensive coding patterns, and where bugs come from.Topic 31 — Flow Control: Branching with casecase/esac for menus and dispatch tables — when if-elif gets too long.Topic 32 — Positional Parameters$1, $@, $*, shift, getopts — how to write a script that takes arguments properly.Topic 33 — Flow Control: Looping with forfor x in list, C-style for, iterating over globs and command output.Topic 34 — Strings and NumbersParameter expansion, arithmetic expansion, the operators bash gives you for both.Topic 35 — ArraysIndexed and associative arrays. When to use them and when to write Python instead.Topic 36 — ExoticaThe grab bag — coprocesses, traps, here-strings, advanced expansion. The chapter you read after writing your first 10 scripts.

How to read these summaries

Treat them as a lookup reference, not a sequential read. The topics are heavily self-contained. If you already know what a pipe is, skip topic 6; if you don't, it's the most useful 10 minutes you'll spend.

Topics 1-10 build on each other if you're new. Topics 11-23 are mostly independent. Topics 24-36 build a single example script across the whole part — read them in order if you're going to write scripts.

Concept companions

Topics

  1. 01What Is the Shell?
  2. 02Navigation
  3. 03Exploring the System
  4. 04Manipulating Files and Directories
  5. 05Working with Commands
  6. 06Redirection
  7. 07Seeing The World As The Shell Sees It
  8. 08Advanced Keyboard Tricks
  9. 09Permissions
  10. 10Processes
  11. 11The Environment
  12. 12A Gentle Introduction To vi(m)
  13. 13Customizing The Prompt
  14. 14Package Management
  15. 15Storage Media
  16. 16Networking
  17. 17Searching For Files
  18. 18Archiving And Backup
  19. 19Regular Expressions
  20. 20Text Processing
  21. 21Formatting Output
  22. 22Printing
  23. 23Compiling Programs
  24. 24Writing Your First Script
  25. 25Starting A Project
  26. 26Top-Down Design
  27. 27Flow Control: Branching With If
  28. 28Reading Keyboard Input
  29. 29Flow Control: Looping With While/Until
  30. 30Troubleshooting
  31. 31Flow Control: Branching With Case
  32. 32Positional Parameters
  33. 33Flow Control: Looping With For
  34. 34Strings And Numbers
  35. 35Arrays
  36. 36Exotica