Free — no signup required

The Core Four: Navigation and Inspection

4 min read

The Commands You Will Use Every Day

Before learning exotic tools, master the concepts behind the four commands that cover 90% of daily CLI work: knowing where you are, seeing what's around you, reading a file, and searching text. These aren't arbitrary incantations — each maps onto a simple model of how Linux organizes and exposes information.

1. pwd and cd — Where am I, and how do I move?

The filesystem is a tree rooted at /. At any moment your shell has a current working directory — a single node in that tree that every relative path gets resolved against. pwd simply asks the kernel "what directory is this process currently in?" and prints the answer.

cd changes that working directory. What matters conceptually is the distinction between absolute and relative paths: a path starting with / is anchored at the root and means the same thing regardless of where you currently stand, while a path without a leading / is resolved relative to wherever you happen to be — so the same relative path can point to completely different places depending on your current directory. The shell also tracks a couple of special reference points as shorthand: your home directory, and the directory you were in immediately before your last move, so you can jump back without retracing your steps.

2. ls — What is here?

ls lists the contents of a directory. A directory listing carries more than filenames — the underlying inode for each entry also stores permissions, ownership, size, and modification time, all of which ls can optionally surface. It also distinguishes ordinary entries from "hidden" ones: by Unix convention, any filename starting with . is treated as hidden from a casual listing. That convention exists specifically for configuration files that need to live in a directory (often your home directory) without cluttering everyday output — the shell config files covered later in this lesson are a prime example.

3. cat and less — Reading files two different ways

cat (concatenate) streams a file's entire contents to standard output in one shot — fine for a short file, but for anything longer than a screen it floods your terminal with no way to scroll back. less solves this by acting as a pager: instead of dumping the whole file at once, it holds the file open and displays it a screen at a time, letting you scroll and search interactively. The distinction matters operationally — reading a multi-gigabyte log file the way you'd read a five-line config file is exactly the mistake a pager exists to prevent.

4. grep — Find text inside files

grep searches text for lines matching a pattern — anything from a literal substring to a full regular expression — and prints the matches. Its real power for operational work is that it doesn't care what kind of file it's looking at: config files, source code, logs, or the piped output of another command are all just a stream of lines to filter. It can search an entire directory tree recursively, invert the match to show everything that does not match, ignore case, or report line numbers — all variations on the same underlying idea of filtering a text stream by pattern.

Composing tools with pipes

The real power of the CLI is not any single command — it's composition. The | (pipe) operator connects the standard output of one process directly to the standard input of the next, as a live stream at the kernel level — no temporary file is written in between. This lets you chain small, single-purpose tools into a pipeline that does something none of them could do alone: filter a log for a pattern and then count the matches, list every running process and then narrow to the one you care about, list files by modification time and then look at only the most recent ones. Each tool in the chain does one narrow thing well; the pipe is what turns a toolbox of narrow utilities into a general-purpose way of processing data.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free