Code Safari

Chapter 106·Beginner·8 min read

The Linux Filesystem, and How to Move Around It

A plain-English guide to the Linux filesystem — the single tree that starts at /, absolute vs relative paths, your home directory and the ~ shortcut, the . and .. shortcuts, and the four commands (pwd, ls, cd, tree) you use to navigate. Where everything lives and how to get there.

July 17, 2026

Every command you type runs somewhere — in a particular folder, on particular files. So before you can usefully copy, move, edit, or run anything, you need a clear picture of where things live and how to move between them. Linux organises everything into a single structure that, once it clicks, is genuinely simple. This chapter is that picture, plus the four commands that let you walk it.

One tree to rule them all

If you've used Windows, you're used to drives: C: for your main disk, maybe D: for another, each its own separate world. Linux doesn't work that way. There is exactly one tree, and it starts at a single directory called the root, written as a lone forward slash: /.

Everything else hangs off that root. Your files, the programs you run, system configuration, even the hardware — all of it appears somewhere under /. A second hard drive doesn't become D:; it gets attached ("mounted") at some folder inside the one tree, like /media/backup. There's only ever one tree.

/
├── bin      programs (commands like ls, cp) live here
├── etc      system-wide configuration files
├── home     everyone's personal folders
│   └── raghav
│       ├── projects
│       └── notes.txt
├── tmp      temporary scratch space, wiped on reboot
└── var      logs, databases, things that change

You don't need to memorise these folders yet. The one idea to hold onto: it's a family tree, and every single file has exactly one place in it. That place is called its path.

A path is just an address

A path is the full address of a file or folder — the sequence of directories you'd walk through to reach it, separated by slashes. Read this one left to right:

/home/raghav/projects/app.py

That says: start at the root /, go into home, then into raghav, then into projects, and there's the file app.py. It's completely unambiguous — there is one and only one file with that path. Slashes separate the steps; the leading slash means "begin at the root."

Absolute vs relative: from root, or from here

This distinction trips up every beginner exactly once, so let's make it stick.

An absolute path starts at the root / and spells out the whole route. /home/raghav/projects/app.py means the same file no matter where you currently are in the system — it's like giving someone your full postal address.

A relative path starts from your current location and describes how to get to the target from there — like telling someone "two doors down on the left." If you're currently standing in /home/raghav, then the relative path projects/app.py points at the very same file, because it means "from here, go into projects, then app.py."

Target: /home/raghav/projects/app.py
Absolute: /home/raghav/projects/app.py
Standing in /home/raghav?
Relative: projects/app.py
Two ways to name the same file

Both are correct; they're just measured from different starting points. Relative paths are shorter and are what you'll type most of the time. Absolute paths are unambiguous and are what you use in scripts and configuration, where "here" could be anywhere.

Home, and the ~ shortcut

Every user on a Linux system gets a home directory — their own private folder for personal files and settings, almost always at /home/yourname (on macOS it's /Users/yourname). It's where your shell drops you when you first log in, and it's the one part of the tree you fully own.

Because you refer to it constantly, the shell gives it a shortcut: the tilde, ~. Anywhere you could type /home/raghav, you can type ~ instead. So ~/projects/app.py and /home/raghav/projects/app.py mean the same thing — and the ~ version keeps working even if you copy the command to a different account. That's why you saw ~/projects in the prompt back in chapter one: the shell shows your location using ~ for your home.

The two most useful shortcuts: . and ..

Two more shorthands appear everywhere, and they're worth burning into memory:

  • . (a single dot) means "the current directory" — right here, where I am now.
  • .. (two dots) means "the parent directory" — one level up the tree.

So cd .. walks you up one level toward the root. Chain them — cd ../.. — to go up two. And ./app.py means "the app.py in this folder," which matters later when you run a program: ./script is how you say "run the script right here," as opposed to a system-wide command.

The four commands that move you around

You navigate the whole tree with a tiny toolkit. Here it is in full.

pwdprint working directory. It answers "where am I right now?" by printing your current absolute path. When you feel lost, this is the reset button.

$ pwd
/home/raghav/projects

lslist. It shows what's in the current directory (or any directory you name). Add -l for a detailed "long" listing with sizes and dates, and -a to reveal hidden files (ones whose names start with a dot, like .git).

$ ls
app.py   README.md   data
 
$ ls -la
drwxr-xr-x  4 raghav  staff   128  Jul 17 09:14 .
-rw-r--r--  1 raghav  staff  2048  Jul 17 09:12 app.py

cdchange directory. It moves you. Give it an absolute path, a relative path, or one of the shortcuts:

$ cd /var/log        # jump to an absolute location
$ cd projects        # go into 'projects' from here
$ cd ..              # up one level
$ cd ~               # home (or just 'cd' with no argument)
$ cd -               # back to wherever you just were

tree — draws the directory as an indented tree, so you can see the shape of a folder and its contents at a glance. (It's not always installed by default, but it's worth adding.)

pwd — where am I?
ls — what’s here?
cd — go somewhere
repeat
The navigation loop you'll run a thousand times

That loop — where am I, what's here, move — is the rhythm of working in a shell. You'll run it so often it becomes muscle memory, and pwd/ls/cd will feel as automatic as glancing around a room.

Why this comes first

It's tempting to rush past navigation to the "real" commands. Don't. Nearly every mistake beginners make in the terminal traces back to acting in the wrong place — deleting files from the wrong folder, running a script against the wrong project, wondering why a command "can't find" a file that's sitting right there under a different directory. Commands operate on your current location by default, silently, so knowing exactly where you are is the safety net under everything else.

Now that you can find your way around the tree, the next chapter puts it to work: creating, viewing, copying, moving, and deleting files — the everyday verbs of getting things done from the command line.

The Linux Filesystem, and How to Move Around It | Code Safari