Everything is a file
One tree, starting at /. Learn to walk it with absolute and relative paths, find the files ls hides, and meet the file that swallows everything you write to it.
Windows gives every drive a letter: C:, D:. Linux has no letters. It has one tree, and everything hangs from a single root written /. Your files, the machine’s settings, even the hardware: all of it has a place somewhere under /.
Learn that tree and you can find your way around any Linux machine, whether it’s your laptop, a server or the container a cluster is running for you.
- Everything starts at /, the root. There is exactly one.
- Each user gets a folder under /home. Yours is /home/panda, and ~ is shorthand for it.
- A full path from the root is absolute: /home/panda/notes.txt means the same file wherever you are standing.
- The machine's own settings live under /etc, as ordinary text files you can read with cat.
Where am I, and how do I get there?
Your shell always stands in one directory, the working directory. pwd prints it. Paths come in two kinds:
- Absolute paths start with
/and are read from the root:/etc/hostname. They mean the same thing wherever you are. - Relative paths don’t start with
/and are read from where you’re standing: from/home/panda,projects/bamboomeans/home/panda/projects/bamboo.
Two names are in every directory: . is the directory itself and .. is its parent. So cd .. climbs one level, and ../../notes.txt climbs two and then picks a file.
You are in /home/panda/projects/bamboo. Which path names /home/panda/notes.txt?
One .. climbs from bamboo to projects, a second climbs to /home/panda, and notes.txt is there. /notes.txt is an absolute path: a file directly under the root, which is something else entirely.
The files ls doesn’t show you
ls skips any name that starts with a dot. That’s a convention, not a security feature: dot-files are mostly settings (.bashrc configures your shell) that would otherwise clutter every listing. ls -a shows them, along with . and ...
ls shows nothing, but ls -a lists .env and .git. What happened?
A leading dot only hides a name from a plain ls. Anyone who can read the folder can list and open them - which is why a .env file full of passwords is no safer for its dot.
Why “everything is a file”
Linux presents far more than documents as files. Devices live under /dev. Running processes appear under /proc, one folder per process ID, with files describing each one. Settings live in /etc. Because they’re all files, the same handful of tools - cat, echo, > - work on every one of them.
The most famous is /dev/null. Anything written to it is thrown away, and reading it gives you nothing at all. It’s where you send output you don’t want: noisy-command > /dev/null.
Everything above ran in your browser. Now try it in a real terminal: any Linux machine, a Mac's Terminal app, or Windows with WSL. Nothing to install beyond that.
Look at your own machine’s tree, its hidden files and its live process files:
pwd
ls -la ~
cat /etc/hostname
head -5 /proc/$$/status # Linux and WSL: your own shell, as a file
echo "gone" > /dev/null; cat /dev/nullOn a Mac there is no /proc; ps -p $$ shows the same shell instead.
Sources
Missions and quizzes above earn their own XP. This marks the lesson done.