Every bioinformatics tool — STAR, GATK, DESeq2, Snakemake — runs from the command line. Before you can use any of them, you need to move around Linux confidently. This lesson teaches you exactly that.
Before you type a single command, you need to understand how Linux thinks about files. This mental model is the foundation of everything else in this course.
In Linux, every file and folder lives inside one giant tree. The very top of the tree is called root, written as /. Everything — your documents, programs, sequencing data — lives somewhere inside that tree.
Your personal home folder is at /home/yourusername. Linux also lets you write this as ~ as a shortcut. So ~/projects means exactly the same as /home/shajedur/projects — it is just shorter to type.
At any moment you are always "standing inside" one specific folder. This is called your current working directory. Think of it like being inside a room in a building — you can look around the room, walk to a neighbouring room, or give someone your full address starting from the building entrance. The terminal always has a current location, and every command you run happens relative to that location unless you say otherwise.
/ # root — the very top of everything ├── home/ │ └── shajedur/ # your home folder — also written as ~ │ ├── projects/ │ └── data/ ├── etc/ # system configuration files ├── usr/ # installed programs live here └── tmp/ # temporary files — cleared on every reboot
There are two ways to describe where a file or folder is:
Absolute path starts from the root / and is complete and unambiguous. It works correctly from anywhere on the system. Example: /home/shajedur/projects/rnaseq/data. If you give this to any command, it always finds the right place.
Relative path starts from wherever you currently are. If you are already inside /home/shajedur, you can write projects/rnaseq/data instead of the full path — it is shorter. But if you run the same command from a different folder, it will fail or go to the wrong place.
Recommendation: when you are learning, use absolute paths. They always work and prevent hard-to-find bugs where a command runs in the wrong folder.
Press Tab to autocomplete folder and file names. Press it twice to see all available options. This prevents typos and saves enormous time — use it constantly from day one.
pwd stands for Print Working Directory. It prints the full absolute path of the folder you are currently inside.
Why does this matter? Because when you run any command that creates, reads, or saves a file — and you do not specify a full path — Linux does it in your current folder. If you do not know where you are, you do not know where your files are landing. This is one of the most common sources of confusion for beginners: "I created the file but I cannot find it."
Run pwd before running any important command, whenever you open a new terminal, or whenever you feel disoriented. It takes less than one second.
pwd /home/shajedur # Reads as: you are inside the shajedur folder, which is inside home, which is inside / # This is your home directory
ls stands for list. It shows the contents of a folder — the names of files and subfolders inside it.
On its own, ls gives you just names in a compact grid. In bioinformatics you almost always want more — especially file sizes, so you know whether a FASTQ file is 50 MB or 50 GB before you try to open it. That is what the flags are for.
The -l flag switches to long format — one item per line with full details. The -h flag makes sizes human-readable — instead of showing 52428800 bytes it shows 50M. You will use -lh together almost every time.
Hidden files in Linux start with a dot (.) and are invisible by default. They include important configuration files like .bashrc (your shell settings). Use -a to show them.
ls # basic list — names only ls -l # long format: permissions, owner, size, date, name ls -lh # long format with human-readable sizes (KB, MB, GB) ls -a # show hidden files too (names starting with .) ls -la # long format AND hidden files — most complete view ls -lh ~/projects # list a specific folder without navigating there
drwxr-xr-x 3 shajedur shajedur 4.0K Jun 7 09:12 projects -rw-r--r-- 1 shajedur shajedur 1.2K Jun 6 17:30 notes.txt
Column 1 — type and permissions: starts with d if it is a folder (directory), - if it is a file. The rest of the letters are read/write/execute permissions — we cover these in Lesson 7.
Column 3 — owner: whose account owns this file. On your own machine this will always be your username.
Column 5 — size: the -h flag makes this show 4.0K, 50M, 2.1G instead of raw byte counts.
Columns 6–8 — date modified: when the file or folder was last changed.
Last column — name: the file or folder name.
cd stands for change directory. It changes your current location in the filesystem — exactly like walking from one room to another.
Linux has two special folder names you need to know. . (single dot) means "the folder I am currently in". .. (double dot) means "the folder one level up — the parent". So cd .. walks you up one level, and cd ../.. walks you up two levels.
~ always means your home folder — no matter where you are. So cd ~ takes you home from anywhere in the entire filesystem instantly.
One very useful trick: cd - (dash) takes you back to wherever you were before your last cd. This is perfect when you are jumping between two folders repeatedly — for example, between your data folder and your results folder.
cd projects # go into projects/ — only works if projects/ exists here cd .. # go UP one level to the parent folder cd ../.. # go up two levels at once cd ~ # go home instantly from anywhere cd /home/shajedur/projects # absolute path — always works regardless of where you are cd - # jump back to the previous directory
After every cd, run pwd to confirm you arrived where you intended. This takes one second and prevents many mistakes — especially when you are learning.
mkdir stands for make directory. It creates new folders.
Without any flags, mkdir creates one folder at a time — but only if the parent folder already exists. For example, mkdir projects/rnaseq/data fails if projects/ does not exist yet, because Linux cannot create rnaseq inside something that does not exist.
The -p flag (short for parents) solves this completely. It creates the entire chain of folders in one command, building each level from top to bottom, skipping any that already exist. In bioinformatics, project folders are always nested — project/data/raw/sample1/ — so you will use -p almost every time. Get into the habit of always using it.
cd ~ # go home first mkdir projects # create one folder in current directory mkdir -p projects/rnaseq/data # create all three levels at once mkdir -p ~/bash-linux-bioinformatics/module-1-foundations # create your course folder # Confirm it was created ls -lh ~/bash-linux-bioinformatics/ drwxr-xr-x 2 shajedur shajedur 4.0K Jun 13 10:00 module-1-foundations
Linux has no recycle bin. When you delete a file with rm, it is gone permanently — there is no undo and no recovery. Always double-check before deleting. We cover rm safely in Lesson 2.
Every Linux command has a built-in manual. You do not need to remember every flag — you just need to know how to look it up quickly.
man ls opens the full manual (called a "man page") for the ls command. Use the arrow keys or Page Up/Down to scroll, and press q to quit. Man pages can look overwhelming — that is normal. Scan for the flag you need and ignore the rest.
ls --help prints a shorter, more readable summary directly in your terminal without opening a full manual. This is often faster for a quick reminder.
which star tells you whether a program is installed and exactly where it lives on disk. If nothing is printed, the program is not installed.
man ls # full manual for ls — use arrow keys to scroll, q to quit man cd # full manual for cd ls --help # quick one-page summary of all ls options which python3 # shows /usr/bin/python3 if installed which star # check if STAR aligner is installed — nothing printed means it is not
| Command | What it does | Key flags |
|---|---|---|
| pwd | Print your current working directory as an absolute path | — |
| ls | List files and folders in the current (or given) directory | -l long format · -h human sizes · -a show hidden |
| cd [path] | Move into a different directory | .. parent · ~ home · - previous location |
| mkdir [name] | Create a new directory | -p create all parent directories too |
| man [cmd] | Open the full manual for a command | press q to quit |
| which [cmd] | Show the full path where a program is installed | — |
Open your Ubuntu terminal and complete all four exercises below. Type every command yourself — do not copy-paste. Muscle memory is how you really learn the command line. After each answer, read the output carefully before moving to the next exercise.
Open a fresh terminal. Find out exactly where you are. Then list everything in your home folder in long format with human-readable sizes. Look at the output — notice which items start with d (folders) and which start with - (files).
💬 Hint: two commands. Run pwd first, then ls -lh ~. Read each output before continuing.
pwd /home/shajedur # You are in your home directory ls -lh ~ total 8.0K drwxr-xr-x 2 shajedur shajedur 4.0K Jun 7 09:00 Desktop drwxr-xr-x 2 shajedur shajedur 4.0K Jun 7 09:00 Documents # d at the start = directory (folder) # - at the start = regular file
Starting from your home directory, create the following nested folder structure in a single command: ~/bash-linux-bioinformatics/module-1-foundations. Then navigate into it and confirm you arrived using pwd.
💬 Hint: mkdir -p creates the entire chain at once. Then cd into the deepest folder and run pwd to verify.
cd ~ mkdir -p ~/bash-linux-bioinformatics/module-1-foundations cd ~/bash-linux-bioinformatics/module-1-foundations pwd /home/shajedur/bash-linux-bioinformatics/module-1-foundations
From inside module-1-foundations/, go up two levels in a single cd command. Confirm where you landed with pwd. Then use cd - to jump back to module-1-foundations/ instantly. Confirm again.
💬 Hint: cd ../.. goes up two levels. cd - jumps back to wherever you just were — no path needed.
cd ../.. pwd /home/shajedur # Two levels up from module-1-foundations = home directory cd - /home/shajedur/bash-linux-bioinformatics/module-1-foundations # cd - took you straight back — no path needed
Without navigating away from your current folder, list all files including hidden ones inside /etc. Then check whether STAR is installed on your machine. Finally, open the manual for mkdir, find what -p does in the description, and press q to close it.
💬 Hint: ls -la /etc lists it without moving. which star checks for STAR. man mkdir opens the manual.
ls -la /etc # Shows all system config files including hidden ones # You will see: passwd, hosts, fstab, hostname, apt/ and many more which star # If STAR is installed: prints something like /usr/bin/STAR # If nothing prints: STAR is not installed yet — that is fine for now man mkdir # Look for -p in the description — it says "make parent directories as needed" # Press q to close the manual