Top terminal commands every developer should know (part 1)
Fourteen navigation, file, and search commands on a safe /tmp demo tree, with GNU versus BSD flag traps.
Published here , updated · 8 sources · Resume reading
Fourteen everyday commands cover move, look, read, change, and search: pwd, cd, ls; cat, less, head, tail; mkdir, touch, cp, mv, rm; find and grep (or rg). This Part 1 runs them on a throwaway /tmp tree and flags GNU versus BSD traps. Part 2 covers processes, pipes, and jobs.
Quick start: build a safe demo tree under /tmp
Work under /tmp/blog-demo (or $HOME/tmp/blog-demo). Never demo recursive deletes of your home directory. The examples use the GNU versions documented in the GNU coreutils manual [1]; macOS ships BSD versions of ls, find, and grep, so the flag traps below matter.
rm -rf /tmp/blog-demo
mkdir -p /tmp/blog-demo/{src,docs,.hidden}
cd /tmp/blog-demo
echo 'hello' > README.md
echo 'print(1)' > src/app.py
echo 'findme-unique-token' > src/needle.txt
echo 'note' > docs/note.txt
printf 'secret\n' > .hidden/key.txt
ls -laCaptured on this host (inode and timestamp columns vary):
total 32
drwxr-xr-x 5 ubuntu ubuntu 4096 Dec 3 12:51 .
drwxrwxrwt 74 root root 12288 Dec 3 12:51 ..
drwxr-xr-x 2 ubuntu ubuntu 4096 Dec 3 12:51 docs
drwxr-xr-x 2 ubuntu ubuntu 4096 Dec 3 12:51 .hidden
-rw-r--r-- 1 ubuntu ubuntu 6 Dec 3 12:51 README.md
drwxr-xr-x 2 ubuntu ubuntu 4096 Dec 3 12:51 srcYou should see six entries: ., .., .hidden, README.md, docs, and src.
Demo tree under slash tmp slash blog-demo: README.md, src with app.py and needle.txt, docs with note.txt, and .hidden with key.txt. Use pwd cd ls to move, find and grep to search, and check GNU versus BSD man pages before copying flags.
Move around and list
pwd prints the working directory. cd /path changes it. cd - returns to the previous directory. ls lists names; ls -l is long form; ls -a includes dot entries; ls -la combines them; ls -lh adds human-readable sizes on GNU ls [1].
cd /tmp/blog-demo
pwd
ls -la
cd src
pwd
cd -Captured on this host:
/tmp/blog-demo
/tmp/blog-demo/src
/tmp/blog-demoWhen a remote box needs SSH host aliases before you cd around, see stop typing the full SSH command every time.
The same short flag can mean different things. On BSD ls, -G turns on color [7]; on GNU ls, -G hides group names in a long listing [4]. Check man ls before you copy a flag between a Linux box and a Mac.
Read files without opening an editor
cat file prints the whole file. less file pages through it (q quits). head and tail show the start or end. Keep these on the demo files first so you do not dump secrets from real projects into scrollback. For shell history that already holds keys, see your shell history may contain API keys.
cd /tmp/blog-demo
cat README.md
head -n 1 src/app.py
tail -n 1 docs/note.txtCaptured on this host:
hello
print(1)
noteCreate, copy, move, and remove inside the demo
mkdir, touch, cp, mv, rm, and rmdir change the tree. Prefer named paths inside /tmp/blog-demo. There is no trash by default. cp copies a file; add -r for a folder.
cd /tmp/blog-demo
mkdir scratch
cp README.md scratch/x.md
mv scratch/x.md scratch/y.md
rm scratch/y.md
rmdir scratch
echo removed_okCaptured on this host:
removed_okIf the terminal freezes mid-command, use the exits in terminal stuck? Do not close the window before killing the session.
Find and search
find . -name "*.txt" walks the tree by name. find . -type f lists files. Label GNU find features such as -printf when you use them [6]; not every BSD find has it (OpenBSD's does not [8]), so check man find on a Mac first.
cd /tmp/blog-demo
find . -name "*.txt"
grep -R "findme-unique-token" .Captured on this host:
./src/needle.txt
./docs/note.txt
./.hidden/key.txt
./src/needle.txt:findme-unique-tokenOn GNU grep, grep -r follows symlinks only when they are named on the command line; grep -R follows all of them [5]. Check man grep on your box.
If ripgrep is installed, prefer it for code search [2]:
cd /tmp/blog-demo
rg -n "findme-unique-token"Captured on this host:
src/needle.txt:1:findme-unique-tokenripgrep is not installed by default on every distribution; use grep -R when rg is missing. For which search tool fits which job, see CLI tools matched to jobs.
Use find when tree is missing
Also know tree as an optional viewer, or use find . -print when tree is missing. Defer pipes, permissions, processes, and package managers to later parts. When you need mode bits and ownership next, see Linux permissions: chmod and chown. The agent and API glossary posts that share this demo tree idea are what is an AI agent and what is an API.
GNU versus BSD traps worth memorizing
Three traps burn hours when someone pastes a Linux snippet onto macOS:
ls --color=autois GNU; BSD color is oftenls -G[4][7].find -printfis a GNU extension; portable scripts stick to-nameand-type[6][8].grep -rversusgrep -Rsymlink behavior differs; read the local man page before recursive searches across trees with links [5].
Install GNU coreutils as gls on a Mac when you need GNU long options in scripts you also run on Linux [1]. Prefer portable short flags in shared docs when you can.
Why PATH matters before you blame the install
If rg or find "vanishes" after an install, print command -v, check PATH order, and only then assume the package failed. Part 1 assumes those names resolve on a normal developer PATH.
A cd inside a script does not move your interactive shell unless you source the script. Run pwd after the script exits to confirm you never left the parent shell.
Mistakes that wreck real trees
Running rm -rf / or a mistyped path outside /tmp while "just practicing." Keep demos under a dedicated throwaway directory.
Copying GNU long options into a BSD man page world without checking [1][7].
cating production .env files into scrollback during a screen share. Use the demo tree first [1].
Shipping scripts that require rg on every CI image. Fall back to grep -R or install ripgrep explicitly [2].
Using find . -name *.txt without quotes so the shell expands the glob before find runs. Quote the pattern: "*.txt" [6].
Depth: a five-minute drill on every new box
Build the same demo tree on the next SSH box you log into and run these commands there before you touch real project paths. Confirm pwd, a hidden listing, a find name search, and a content search. That five-minute drill surfaces missing tools and BSD flag mismatches before a deploy script fails.
When you edit remote configs in a hurry, pair this page with vim quick start on a remote box. When Part 2 is next, move to pipes and process control instead of inventing more navigation flags here.
Depth: what Part 1 deliberately skips
Pipes (|), redirection (>, >>), permissions (chmod, chown), process control (ps, kill, jobs), and package managers belong in later parts so this page stays navigable. Jumping ahead without a safe tree is how people delete the wrong path while learning rm. Finish the drill here, then open Part 2 for processes and pipes.
Browse the Dev explainers topic.
Send this to the friend who freezes every time they have to open a terminal.

Keep this guide
Filed under Dev tools, Dev explainers
Questions about this guide
Is this an official Linux Foundation top list?
No. It is an editorial Part 1 set for navigation, files, and search. Later parts cover pipes, permissions, and processes.
Will these flags match macOS Terminal?
Not always. macOS ships BSD tools by default. Prefer portable short flags here, or install GNU coreutils as gls on Mac when you need GNU long options.
Does every distro ship ripgrep?
No. Use grep -R when rg is missing. Install ripgrep when you want faster code search.
Sources
- ripgrep repository, accessed 2026-11-12github.com
- FreeBSD ls(1) manual page, accessed 2026-11-12man.freebsd.org
- OpenBSD find(1) manual page, accessed 2026-11-12man.openbsd.org