Basic Bash training
Basic Bash Training
The command line looks intimidating until you realise it’s just typing sentences a computer understands. Learn the handful of commands that unlock everything else — including bioinformatics tools.
Getting a Real Terminal
SetupThe practice terminal further down is great for learning the commands, but eventually you’ll want a real one open on your own computer. Pick your operating system below.
Windows — via WSL
Windows doesn’t ship with a proper bash terminal, so you’ll use WSL (Windows Subsystem for Linux) — a real Linux environment that runs alongside Windows. This is what our bioinformatics training assumes too.
wsl into PowerShell any time, or open “Ubuntu” from the Start menu, to get back to your terminal.
Mac — Terminal.app
macOS has a real terminal built in already — no installation needed.
Linux — your desktop’s terminal app
Every Linux desktop ships with a terminal app already — the exact name depends on your desktop environment.
The Terminal Window
ConceptWhen you open a terminal, you’ll see something like this, called a prompt. It’s waiting for you to type a command and press Enter.
trainee@yourcomputer:~$ _
Everything you do lives inside folders (called directories in bash-speak), just like Finder or File Explorer — except you navigate them by typing, not clicking.
Where Am I? Where Can I Go?
pwd · ls · cdThree commands answer almost every “where am I” question:
# Print Working Directory — shows exactly where you are pwd # LiSt — shows what's inside the current folder ls # Change Directory — move into a folder cd reads
cd .. moves you up one folder. cd ~ or just cd takes you straight home.
Making Things
mkdir · touch · cp · mv · rmOnce you can move around, you’ll want to create, copy, and clean up:
# MaKe DIRectory — create a new folder mkdir results # create an empty file touch notes.txt # CoPy a file cp genome.fasta results/genome_backup.fasta # MoVe (or rename) a file mv notes.txt results/notes.txt # ReMove — careful, this doesn't go to a Recycle Bin! rm old_file.txt
rm is permanent. There’s no undo, so always double-check what you’re about to delete with ls first.
Looking Inside Files
cat · echo · >cat prints a file’s contents straight to the screen — great for a quick peek at something small:
cat notes.txt
echo prints text back at you — and combined with >, it can write that text into a file:
# prints to the screen echo "Phages are viruses that infect bacteria" # the > sends the output into a file instead of the screen echo "Phages are viruses that infect bacteria" > notes.txt
> overwrites a file. >> (two of them) adds to the end without erasing what’s already there.
Shortcuts & Superpowers
Tab · * · | · –helpA few habits that make the terminal dramatically faster and friendlier:
# press Tab while typing a name — it auto-completes it for you cd rea[Tab] # * is a wildcard — matches anything ls *.fastq # | (pipe) sends one command's output into another cat notes.txt | grep phage # almost every tool will explain itself if you ask ls --help
Ctrl + C almost always cancels it safely.
Practice Terminal
Try it yourselfThis is a real, working (simulated) terminal — type into it below. You start in a home folder with a few sample phage files already inside. Type help to see everything it understands.
Try: ls → cd reads → ls → cat phage_notes.txt → cd ..
Quick Check
Self-testCheat Sheet
| Command | Does |
|---|---|
pwd | Print the current folder path |
ls | List what’s in the current folder |
cd <folder> | Move into a folder (cd .. to go up, cd ~ for home) |
mkdir <name> | Create a new folder |
touch <name> | Create a new empty file |
cat <file> | Print a file’s contents to the screen |
echo "text" > file | Write text into a file (overwrites) |
cp <src> <dest> | Copy a file |
mv <src> <dest> | Move or rename a file |
rm <file> | Delete a file — permanently |
clear | Clear the terminal screen |
man <command> | Open the manual for a command |
--help | Add to almost any command for quick usage info |