Terminal and tree
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.
Files live in a tree of folders, also called directories. The top is the root, written /. A path lists the folders to walk through, joined by /: /home/sam is Sam's home folder, nicknamed ~.
Looking and moving
The shell always stands in one folder, the working directory: the blue marker. pwd (print working directory) prints its path. A new terminal starts in your home folder, /home/sam.
ls lists the working directory: a file, notes.txt, and a folder, photos. Options, or flags, start with a dash and change what a command does. ls -a shows all, even . (this folder) and .. (the one above).
cd (change directory) moves you. cd photos uses a relative path: it starts from where you are now. The marker steps down into photos, so pwd now prints /home/sam/photos.
cd .. goes up one level, back to sam. A path that starts with / is absolute: it starts at the root, so cd /usr/bin works from anywhere. cd ~ jumps straight back home.
Changing files
mkdir makes a new folder, project. cp copies a file: project now holds its own notes.txt. mv moves or renames: notes.txt becomes todo.txt. Both take the source first, then where it goes.
rm deletes a file for good. It does not go to a Trash or Recycle Bin, and rm does not ask first. Read the line twice before pressing Enter; rm -i asks before each file.
cat prints a whole file into the terminal: the copy in project says buy milk. For long files, less shows one screen at a time: Space for the next page, q to quit. Neither changes the file.
Plumbing and help
A pipe | feeds one command's output into the next: ls | wc -l counts the 2 entries (wc -l counts lines). A redirect > writes the output into a file instead: pwd > where.txt. Careful: > replaces what the file held.
Environment variables are named settings that programs the shell starts receive. HOME holds your home folder. PATH lists folders, split by :, where the shell looks for commands. For ls it finds /usr/bin/ls and runs that program.
Stuck? Many commands print a usage guide with --help. man ls opens the full manual page for ls, shown in a pager like less (q quits). Options differ between systems, so check the manual on yours.
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.