Unix Bootcamp: Navigation
The Tree of Data
Before you type a single command, you must visualize where you are.
Your computer’s file system is an inverted tree. The “Root” (/) is at the top, and folders (branches) grow downwards.
- In Windows/Mac, you see this as clicking folders.
- In Unix, you are “blind.” You can only see what is immediately around you.
To survive, you need to constantly answer two questions:
- Where am I?
- What is here?
The “Holy Trinity” of Navigation
You will type these three commands more than any others in your career.
1. pwd (Where am I?)
Print Working Directory. This is your GPS. It tells you the exact path from the Root to your current location.
$ pwd
/home/pradyumna/experiments
- Tip: Always run this first when you open a terminal.
2. ls (What is here?)
LiSt. Shows the files in your current folder. By default, it hides details.
$ ls
data/ scripts/ results.txt
The Power Move: ls -lh
Biologists deal with massive files. Standard ls is useless for checking if a file is 5KB or 50GB.
-l: Long format (permissions, owner, size).-h: Human-readable sizes (K, M, G).
$ ls -lh
-rw-r--r-- 1 prady users 5.2G Dec 15 10:00 genome.fa
Now you know that genome.fa is 5.2 Gigabytes.
3. cd (Take me there)
Change Directory. Moves you up and down the tree.
- Go Down:
cd data(Enter the ‘data’ folder) - Go Up:
cd ..(Back to parent) - Go Home:
cd(Back to your user folder)
Practice: The “Blindfold” Exercise
Open your terminal and try to navigate without using your mouse.
- Open Terminal.
- Type
pwdto confirm you are in your home folder. - Type
lsto see your Desktop, Downloads, etc. - Type
cd Desktop(orcd Downloads). - Type
ls -lhto see what huge files you have downloaded recently.