Command line — cheat sheet
From: fundamentals/05-command-line.md.
- Command line / terminal / shell / console / cmd: interchangeable names for a textual interface to control the computer, as opposed to a GUI file browser.
- Unix-based (macOS, Linux) terminals share the same core commands; Windows isn't Unix-based, so a Unix-compatible layer (git bash, or WSL2 for a full Linux env) is needed to use them there.
- Working directory: the one folder you're "in" at any time (like a file browser's currently open folder).
pwdprints it. - Paths:
- absolute — from the filesystem root, works regardless of current directory.
- relative — relative to the current working directory.
.= current directory,..= parent directory,~= home directory. Combinable (cd ~/Code,cd ~/..).
- Commands take arguments, space-separated, like a function call.
man <command>opens its manual.
Command reference
| Command | Does |
|---|---|
pwd | print working directory |
cd <path> | change directory |
ls / ls -la | list directory contents / with details + hidden files |
mkdir <name> | create a directory |
touch <name> | create an empty file |
mv <src> <dest> | move (or rename) a file/folder |
cp <src> <dest> | copy a file/folder |
rm <path> | delete a file, immediately and permanently |
rm -r <path> | delete a folder recursively, immediately and permanently |
&& chains commands: mkdir example && cd example.
Careful: rm/rm -r delete immediately with no trash/recycle bin — there's no undo, so double check the path first.