Free cheat sheet
Terminal survival cheat sheet
The two dozen commands that cover most of your first month in the Mac terminal, each in plain English, with what to ask AITerm instead.
Download the PDF · or print this page with ⌘P.
Find your way around
pwd- Shows the folder you are in right now (“print working directory”).In AITerm: “which folder am I in?”
ls·ls -la- Lists what is in this folder.
-laadds sizes, dates and hidden files, the ones whose names start with a dot.In AITerm: “show everything in this folder, including hidden files” cd Documents- Moves into a folder.
cd ..goes up one level,cdon its own goes to your home folder (~), andcd -goes back to the last folder. open .- Opens this folder in Finder.
open report.pdfopens a file in its usual app.In AITerm: “open this folder in Finder”
Files and folders
mkdir notes- Makes a new folder.
mkdir -p a/b/cmakes the whole path at once. touch todo.txt- Creates an empty file, or updates the date on one that exists.
cp a.txt b.txt- Copies a file;
cp -Rcopies a folder. Ifb.txtexists it is replaced without asking. Add-ito be asked first. mv old.txt new.txt- Moves or renames a file or folder. Like
cp, it replaces an existing file without asking unless you add-i. rm file.txt- Deletes at once. It does not go to the Trash, and there is no undo.
rm -r folderdeletes a folder and everything in it. Read the path twice, and stop before anyrm -rfyou don’t fully understand, especially withsudoor a*.AITerm marks a delete Destructive. The Work and Production safety profiles ask before it runs; Locked Down blocks it.
Look inside and search
cat notes.txt- Prints a whole file to the screen. Best for short files.
less log.txt- Shows a long file one screen at a time. Space for the next page,
/wordto search,qto quit. grep -i "error" log.txt- Shows the lines that contain a word;
-iignores capitals.grep -r "TODO" .searches every file in and below this folder. find . -name "*.pdf"- Finds files by name in this folder and every folder inside it. Keep the quotes around the pattern.In AITerm: “find the PDFs in my Downloads folder”
Get help, stay in control
man ls- Opens the manual for a command. Space to page,
qto quit. Many built-in Mac commands don’t understand--help, so tryman. history- Lists commands you ran before. The up arrow brings back the last one, and Ctrl-R searches them as you type.
- Tab
- Finishes a file or command name for you. When several names match, it shows the choices.
- Ctrl-C
- Stops the command that is running and gives you the prompt back.
clear- Clears the screen. Nothing is undone; your files are untouched.
Power tools, used carefully
sudo …- Runs one command as an administrator. It asks for your Mac password, and nothing appears as you type it. Use it only when you understand the command and why it needs admin rights, never on a line you copied without reading.
brew install wget- Homebrew installs command-line tools (get it at brew.sh).
brew searchfinds one,brew updaterefreshes Homebrew’s list,brew upgradeupdates what you installed. Don’t putsudoin front ofbrew. git status- In a project folder, shows changed, staged and new files.
git log --onelinelists recent commits, one per line.In AITerm: “show me what changed in this project” chmod +x script.sh- Lets a script run, so
./script.shworks. Avoidchmod 777: it lets every user on the Mac change the file. which python3- Shows the full path of the program that runs when you type a command’s name.
du -sh *·df -hdu -sh *shows how big each item in this folder is;df -hshows how much space is free.In AITerm: “what is taking up space in this folder?”
Let AITerm help
- Plain English
- Type what you want in the input bar. AITerm proposes a command you can edit; Return runs exactly what is shown, Escape drops it.
/explain· ⌘⇧E- Explains your last command or its output, or a command you give it, like
/explain chmod +x script.sh. It never runs anything. /fix· ⌘⇧F- After a command fails, proposes a corrected one for you to review. Add a follow-up, like “we use pnpm in this project”.
- Risk badges
- Safe, Caution, Destructive, Irreversible. Click a badge to see why, and for risky commands a dry-run preview.
From ai-term.com/cheatsheet.html · AITerm is free for Apple Silicon Macs on macOS 13 or later.