shellHOME/home/samPATH/usr/bin:/bin/$ echo hellohello$ $ pwd/home/sam$ lsnotes.txt photos$ ls -a. .. notes.txt photos$ cd photos$ pwd/home/sam/photos$ cd ..$ cd /usr/bin$ cd ~$ pwd/home/sam$ mkdir project$ cp notes.txt project$ mv notes.txt todo.txt$ lsphotos project todo.txt$ rm todo.txt$ lsphotos project$ cat project/notes.txtbuy milk$ less project/notes.txt$ ls | wc -l2$ pwd > where.txt$ cat where.txt/home/sam$ echo $PATH/usr/bin:/bin$ which ls/usr/bin/ls$ ls --helpUsage: ls [OPTION]... [FILE]...$ man lshomeusrsam ~notes.txtbinphotosprojectls
Left: the shell, its environment variables and the terminal you type intoRight: the file system tree; flat traces join each folder to the one aboveMovers: the working-directory marker, commands going in and answers coming outLeft: the shell, its environment variables HOME and PATH, and the terminal card where commands are typed and answers appear. Right: the file system tree, from / at the top down to the files, with a blue marker on the working directory. Each command hops from its line to the shell; the shell walks, reads or changes the tree, and the answer hops back. The outputs are what bash and the GNU tools print on Linux; this page computes them with a tiny model of the shell. macOS uses zsh by default and BSD versions of ls, wc and others, so some options and spacing differ.

Terminal and tree

  1. A terminal is a window for typing commands. Inside it runs a shell: a program that reads each line you type, runs it, and prints the result. The $ is the prompt: the shell is waiting for you.

Looking and moving

Changing files

Plumbing and help

What happens

;; step 1/12 · terminal
terminal
  $ echo hello
  hello

working directory   /home/sam

The outputs are what bash and the GNU tools print on Linux; this page computes them with a tiny model of the shell. macOS uses zsh by default and BSD versions of ls, wc and others, so some options and spacing differ. Strictly, rm removes a name (a directory entry), and the space is freed once nothing else uses the file. Recovery tools sometimes find old data, but treat rm as permanent. Desktop file managers move files to a Trash; rm does not.