Every file on a Linux system has an exact, unambiguous location described as a path — and the four commands in this lesson are how you find out where you are, see what's around you, and move somewhere else. Everything later in this domain builds on this model.
2 min read
A Linux filesystem is one connected tree, starting from a single root
directory written / — unlike Windows' separate drive letters (C:, D:),
every file and directory on a Linux system, regardless of what physical disk
it's actually stored on, has one unambiguous path starting from that same
root: /home/user/projects/app/main.py.
pwd (print working directory) — shows the full path of where you
currently are:
$ pwd
/home/user/projects/appls (list) — shows what's inside the current directory:
$ ls
main.py requirements.txt README.md
$ ls -la # -l for details (permissions, size, date), -a for hidden files too
drwxr-xr-x 5 user user 160 Sep 11 10:00 .
-rw-r--r-- 1 user user 245 Sep 11 09:58 main.py
-rw-r--r-- 1 user user 87 Sep 10 14:22 .gitignore <- hidden files start with a dotcd (change directory) — moves you somewhere else:
$ cd projects/app # move into a subdirectory
$ cd .. # move up one level
$ cd ~ # jump to your home directory, from anywhere
$ cd - # jump back to wherever you just came fromAn absolute path starts from the root (/home/user/projects) and means
the exact same thing no matter where you currently are. A relative path
(projects/app, or ../sibling-folder) is interpreted relative to your
current directory — the same relative path typed from two different
locations can point to two completely different places. Scripts and
configuration that need to work reliably regardless of where they're run from
generally prefer absolute paths for exactly this reason.
/home/user/projects/app <- absolute: always the same place
./app <- relative: means something different
../app <- depending on where you currently are
. — the current directory.. — the parent directory, one level up~ — your home directory (shorthand for /home/your-username)- (only with cd) — the previous directory you were just inTyping a partial file or directory name and pressing Tab auto-completes it (or shows the possible matches if there's more than one) — an essential habit that both speeds up navigation dramatically and avoids typos in long paths. This single habit, more than memorizing any specific command, is what makes day-to-day command-line work feel fast rather than tedious.
Check your understanding
A quick comprehension check — not tracked, not graded, just for you.
1. What's the key difference between an absolute and a relative path?
2. What does `cd -` do?
3. Why does tab completion matter for practical command-line speed?
Linux & the Command Line