Full Byte Developer.

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

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.

bash
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 -la

Captured on this host (inode and timestamp columns vary):

text
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 src

You should see six entries: ., .., .hidden, README.md, docs, and src.

/tmp/blog-demo README.md src/ app.py needle.txt docs/ note.txt .hidden/ key.txt pwd cd ls to move; find grep rg to search; keep demos under /tmp GNU vs BSD: check man before copying long flags [1][4][7]

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].

bash
cd /tmp/blog-demo
pwd
ls -la
cd src
pwd
cd -

Captured on this host:

text
/tmp/blog-demo
/tmp/blog-demo/src
/tmp/blog-demo

When 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.

bash
cd /tmp/blog-demo
cat README.md
head -n 1 src/app.py
tail -n 1 docs/note.txt

Captured on this host:

text
hello
print(1)
note

Create, 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.

bash
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_ok

Captured on this host:

text
removed_ok

If the terminal freezes mid-command, use the exits in terminal stuck? Do not close the window before killing the session.

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:

  1. ls --color=auto is GNU; BSD color is often ls -G [4][7].
  2. find -printf is a GNU extension; portable scripts stick to -name and -type [6][8].
  3. grep -r versus grep -R symlink 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: quoting, globs, and hidden files

Shells expand globs before many commands see them. Quoted "*.txt" stops the shell from expanding the glob before find runs [6]. The same habit helps grep patterns that contain spaces or shell metacharacters.

Hidden files (names starting with .) stay invisible to plain ls. Use ls -a or ls -la when you need them [1][4]. The demo .hidden/key.txt exists to make that muscle memory automatic before someone "loses" a dotenv file that was never missing.

cp -r and rm -r recurse. Prefer named targets inside the demo tree until the flags feel boring. mkdir -p creates parents without erroring when they already exist, which is why the setup script uses it [1].

Tab completion and cd with absolute paths reduce typos on unfamiliar hosts. Relative ../ chains are fine once you can read pwd without thinking. If an agent shell starts with a minimal PATH, interactive aliases may be invisible; see CLI tools matched to jobs for that failure mode.

Keep a personal cheat sheet short: ten commands you actually type, with the one BSD or GNU flag that burned you last month. Long posters on the wall do not beat a five-minute drill on a new box.

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.

A tidy tree of dark folder boxes and small file slabs on a navy floor, with a teal path line walking the branches and an amber search beam highlighting a few matching nodes, shown as a clean geometric workspace with no letters, flags, or command names.
Move, list, copy, and search inside a safe throwaway tree before you touch a real repo.

Keep this guide

By Full Byte Developer

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

Next in this stack