Where am I?
The filesystem is a tree of directories rooted at /. pwd prints your current position in that tree; cd moves you. Absolute paths start from /; relative paths start from where you are now.
Every command you run happens somewhere — in a specific directory. If you don’t know where you are, you can’t reliably name files or understand why a command fails. The filesystem has a shape — a tree — and two commands let you read your position in that tree and move through it. These two commands underlie almost everything else you will do at the terminal.
By the end of this lesson you will know how the Linux filesystem tree is structured, how to print your current location with pwd, and how to move with cd using both absolute and relative paths.
After this lesson you can describe the Linux filesystem tree, use pwd to print the working directory, use cd to navigate using absolute paths (starting with /) and relative paths (starting from where you are), and use the shortcuts ., .., and ~.
The filesystem is a single tree rooted at /. On Linux (and Unix-like systems), every file and directory lives somewhere inside one tree. The root of that tree is called / (a single forward slash). Under / sit well-known top-level directories: /etc (configuration files), /home (user home directories), /var (variable data like logs), /usr (programs), /tmp (temporary files). Every path on the system starts from /.
There are no drive letters like C:\. Everything — including external drives mounted after boot — is attached somewhere inside the same tree.
pwd prints your working directory. The shell always has a current working directory — the directory it is “standing in” right now. Commands that accept a filename use this directory as the default location if you don’t specify a path. pwd (print working directory) tells you where that is:
pwdTypical output:
/home/aliceThat /home/alice is an absolute path: it starts from the root / and lists every directory on the way to the destination.
cd moves your working directory. Pass an absolute path and you jump to exactly that location regardless of where you are now:
cd /etc
pwdOutput:
/etcPass a relative path and the shell interprets it starting from your current directory:
cd /home/alice
cd projects
pwdOutput:
/home/alice/projectsprojects was resolved relative to /home/alice (where you were), so you ended up at /home/alice/projects.
Three navigation shortcuts save constant typing. The shell defines three special directory names:
.— the current directory itself.cd .does nothing useful; butls .lists here...— the parent directory.cd ..moves one level up toward the root.~— your home directory (e.g./home/alice).cd ~always returns you home. Barecdwith no argument does the same.
These can be combined: cd ../../etc means “go up two levels, then into etc.”
A navigation session.
Starting from /home/alice, navigate to /etc, look around, then return home:
pwd/home/alicecd /etc
pwd/etcls(lists config files in /etc)
cd ..
pwd/cd ~
pwd/home/aliceNotice cd .. from /etc went to / (the parent of /etc), not to /home/alice. The working directory moved one step toward the root of the tree.
▸Why this works
On macOS, the filesystem tree works the same way and pwd/cd behave identically. The top-level layout differs from Linux: /Users instead of /home, /System and /Library instead of /usr/lib, and so on. The concepts — root, absolute paths, relative paths, ./../~ — are identical.
▸Common mistake
A common mistake is confusing / (the root directory) with ~ (your home directory). Running cd / takes you to the very top of the tree — from there you can see etc, home, var, and the rest. Running cd ~ takes you to your personal directory inside /home. They are very different places. Always run pwd if you’re unsure where you are.
Your working directory is /home/alice/projects. You run: cd ../docs. What is your working directory afterwards?
The Linux filesystem is a tree rooted at /. Every file has a location expressed as a path through that tree. pwd prints your current working directory — your position in the tree. cd moves you: give it an absolute path (starts with /) to jump to an exact location, or a relative path (starts from where you are now) to navigate step by step. The shortcuts . (here), .. (parent), and ~ (home) speed up navigation. Run pwd whenever you feel lost — the shell always knows where it is, and now so do you.
Practice
Start at the top. Tasks go easiest → hardest: recall a fact, apply it to a case, then a senior-level stretch. Open one, attempt it, then reveal.
Something unclear?
Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.