Terminal Toolbox

A quick reference for the core Linux commands used throughout this course. Come back here whenever you need a reminder — this page is a companion to the exercises, not a replacement for working through them.

Orientation & navigation

Finding out where you are and moving around the filesystem.

pwd

Prints the absolute path of your current working directory. Your first move whenever you're unsure where you are.

ls

Lists the contents of the current directory (or a directory you specify).

ls -lh

Lists contents in "long" format — permissions, owner, size, and modification date — with file sizes shown in human-readable units (K, M, G) rather than raw bytes.

cd

Changes your current working directory. cd .. moves up one level; cd with no argument returns you to your home directory; cd - returns you to the previous directory you were in.

Files & directories

Creating, copying, moving, and removing things.

mkdir

Creates a new, empty directory. mkdir -p a/b/c creates nested directories in one go, including any missing parent directories.

cp

Copies a file (or, with -r, a directory and its contents) to a new location, leaving the original in place.

mv

Moves or renames a file or directory. There is no separate "rename" command — moving a file to a new name in the same directory is how renaming works.

rm

Deletes a file permanently — there is no undo and no recycle bin. Use rm -r to remove a directory and its contents. Always double-check the path before pressing enter.

Inspecting files

Looking inside files without necessarily opening the whole thing.

head

Prints the first lines of a file (10 by default). Use head -n 20 file to control how many lines are shown. Safe to use on huge files since it only reads the start.

less

Opens a file for interactive, scrollable viewing without loading the whole thing into memory at once. Arrow keys / space bar to scroll, /pattern to search, q to quit.

cat

Prints an entire file's contents to the screen. Useful for small files; avoid on very large files since it will flood your terminal.

file

Inspects a file's actual content to report its real type (e.g. "gzip compressed data", "ASCII text"), regardless of what its extension claims.

du

Reports disk usage. du -sh . summarises the total size of the current directory in human-readable units — far more useful day-to-day than the default verbose, per-file output.

Compression

Most genomic data is distributed compressed.

gzip / gunzip

gzip file compresses file into file.gz (and removes the original by default). gunzip file.gz reverses this. Add -k to either command to keep the original file as well as the new one.