Linux File System Basics
Understand how Linux organizes everything as files in a single tree, and learn to move around it with confidence.
In Linux, everything is a file — your documents, your hard drives, even your
keyboard and network connections. All of these live in a single upside-down tree
that starts at the root directory, written as /.
There is no C: or D: drive like on Windows. Instead, additional disks are
mounted into folders inside that one tree. This single-tree idea is the most
important mental model in Linux.
A few key directories you’ll meet everywhere:
/— the root of everything/home— personal folders (yours is/home/yourname, shortened to~)/etc— system-wide configuration files/var— files that change a lot, like logs (/var/log)/usr— installed programs and their data/tmp— temporary scratch space, wiped on reboot
graph TD R["/ (root)"] --> H["/home"] R --> E["/etc"] R --> V["/var"] R --> U["/usr"] R --> T["/tmp"] H --> A["/home/alex"] V --> L["/var/log"] A --> N["notes.txt"]
Imagine you just logged in. Here’s a quick tour of finding your way around:
pwd # print working directory -> /home/alex
ls -la # list everything, including hidden dotfiles
cd /var/log # jump to the system logs
cd ~ # go home (~ is shorthand for /home/alex)
cd .. # move up one directory
tree -L 1 / # see the top level of the whole treeThe combination of pwd, ls, and cd is how you build a mental map of any
machine you land on — even one you’ve never seen before.
Try these on any Linux machine (or WSL / a container):
- Find your home directory’s absolute path with
pwd. - List all files in
/etcthat start withh— hint:ls /etc/h*. - Create a folder
~/practice, move into it, then create an empty file withtouch hello.txt. Confirm withls -l. - From inside
~/practice, navigate to/var/logusing onecdcommand, then return to~/practiceusingcd -(jump back).
Cheat Sheet▾
| Command | What it does |
|---|---|
pwd | Show current directory |
ls -la | List all files (long, including hidden) |
cd <dir> | Change directory |
cd ~ / cd | Go to home |
cd - | Go to previous directory |
mkdir -p a/b/c | Make nested directories |
touch file | Create an empty file / update timestamp |
cp -r src dst | Copy (recursively) |
mv src dst | Move or rename |
rm -r dir | Remove recursively (careful!) |
find / -name foo | Search the tree by name |
du -sh dir | Disk usage of a directory |
Common Interview Questions▾
What does the root directory `/` represent?
It’s the single top of the entire Linux filesystem tree. Every file and every mounted disk lives somewhere underneath it — there are no separate drive letters.
What's the difference between an absolute and a relative path?
An absolute path starts from / and is unambiguous from anywhere
(/home/alex/file). A relative path is interpreted from your current working
directory (./file, ../file).
Where would you look for application logs on a typical Linux system?
/var/log — for example /var/log/syslog, /var/log/auth.log, or service-
specific subfolders. On systemd machines you’d also use journalctl.
Troubleshooting Scenarios▾
“No such file or directory” when you’re sure it exists.
You’re probably using a relative path from the wrong location. Run pwd to see
where you actually are, then use an absolute path or cd to the right place.
rm -rf deleted more than you expected.
A stray space turns rm -rf ./build into rm -rf . /build. Always double-check
the path, and prefer ls first to preview what a glob matches.
“Permission denied” reading a file in /etc or /var.
System files are often owned by root. Read them with sudo cat <file>, but
only edit configuration you understand.