This page is a working reference for the commands you'll type most often. If you can move around the filesystem, list directory contents, read a file, search for text, and connect commands together with pipes, you can do 90% of what any terminal task asks of you. The rest is just specific tools layered on this base.
Where am I and what's here?
pwd — print working directory
Tells you the absolute path of where you currently are in the filesystem.
ls — list directory contents
List what's in the current directory (or any directory you name).
The flags combine: ls -lhart = long format, human sizes, all files, reverse time order. The single most-typed flag combination in the world is probably ls -la.
cd — change directory
Reading files
cat — print whole file to screen
Use for short files. For long files use less instead — cat on a 10,000-line log file scrolls past too fast.
less — page through a file
Opens the file in a pager. Inside less: arrows or j/k to scroll line by line; space or Page Down to page; g to jump to top; G to jump to end; /pattern to search forward; ?pattern backward; n next match; q to quit.
head and tail — first/last lines
tail -f is the standard way to watch a log file in real time.
Making changes — copy, move, delete
cp, mv, rm
rm deletes immediately and permanently. There is no recycle bin. Especially scary: rm -rf / would erase the entire system. Build the habit of typing the destination first and double-checking before pressing Enter.mkdir, touch, rmdir
Finding things: find and grep
find — find files by name, type, age, size
grep — find text inside files
Pipes and redirects — connecting commands
The Unix philosophy: small tools that do one thing well, connected together. Pipes (|) and redirects (>, >>, <, 2>) are the glue.
Pipe — |
Sends the output of the left command as the input to the right command.
Redirect output to file — > and >>
Single > replaces. Double >> appends. Use append when you're building up a log over time; use overwrite when you want a fresh file.
Redirect input from file — <
Most commands accept filenames directly, so < is less common in practice. Still useful when a program only reads from stdin.
Redirect error stream — 2> and 2>&1
Programs have two output streams: stdout (1) for normal output, stderr (2) for errors. By default both print to your terminal.
/dev/null trick. /dev/null is the Unix "discard" pseudo-file. Anything you redirect to it disappears silently. Use it to hide noisy error output you don't care about.Permissions — the quick read
When you run ls -l, the leftmost column looks like -rw-r--r--. That's a 10-character permission string:
- Position 1: file type.
-= regular file,d= directory,l= symlink. - Positions 2–4: owner permissions.
rwx= read, write, execute. - Positions 5–7: group permissions.
- Positions 8–10: everyone else.
For the full treatment of users, groups, and permissions — including chmod and the setgid bit — see the Linux Administration reference. Permissions are covered in much greater depth there.
These commands are the muscle memory of a Linux user. You don't need to memorize all of them today — you'll learn the flags you need as you need them. What matters is recognizing the pattern: small tools, connected with pipes, with redirects to capture output. Once that pattern is automatic, the terminal stops being intimidating and becomes a place you get work done.
References
Formatted in APA 7. Alphabetized by first author's last name.
- GNU Project. (n.d.). GNU coreutils manual. Free Software Foundation. https://www.gnu.org/software/coreutils/manual/
- Kerrisk, M. (n.d.). find(1): Linux manual page. Linux man-pages project. https://man7.org/linux/man-pages/man1/find.1.html
- Robbins, A. (2005). Effective awk programming (3rd ed.). O'Reilly Media.