Linux File System Hierarchy Explained: /etc, /var, /home and Where Everything Lives
The first time you open a Linux terminal and type ls /, you get a wall of strange short names: etc, var, usr, opt, proc, sys. It looks random. It isn’t. Linux follows a standard layout called the Filesystem Hierarchy Standard, and every directory has a job. Learn the map once, and you’ll know exactly where to look for a config file, a log, or a runaway process — on any Linux machine, forever.
The Root: /
Everything starts at /, the root directory. Every file on the system lives somewhere under it. If you’re a Windows user, think of / as the C: drive of Linux — except there’s only one of them, and every disk and device is mounted somewhere inside it.
Your Home: /home
/home is where user accounts live. Your personal files, your downloads, your shell configuration — all under /home/yourname. When something goes wrong with your account, this is the first place to look. And when you’re securing a system, remember: a user’s home directory is theirs, but anything they put there can be read by any program they run.
Configuration: /etc
/etc holds system-wide configuration files — the settings that decide how the machine behaves. Want to see how SSH is configured? That’s /etc/ssh/sshd_config. DNS settings? /etc/resolv.conf. The list of users? /etc/passwd. Two things matter here for security: Almost everything in /etc is a plain text file. You can read it, understand it, and change it with a text editor. That’s a feature — and a risk. Only root can write to most of /etc. If a normal user account can modify files here, something is very wrong.
Variable Data: /var
/var is where files that change constantly live — most importantly, logs. System logs sit in /var/log, including /var/log/auth.log (login attempts) and /var/log/syslog (general system events). When you’re investigating a suspicious login or a crashed service, /var/log is where the evidence is. Also in /var: web server data (/var/www), mail queues, and package caches. If your disk fills up unexpectedly, /var/log and /var/cache are the first suspects.
Programs: /usr and /bin
- /usr/bin — most user programs live here (python3, curl, grep).
- /bin — essential commands needed even before the system fully boots (on modern Linux, usually a link to /usr/bin).
- /usr/local/bin — programs you install yourself, outside the package manager.
From a security view, these directories should be read-only for normal users. If an attacker can write to /usr/bin, they can replace a system tool with a malicious one — which is why these directories are owned by root.
Temporary Files: /tmp
/tmp is scratch space: any user can write here, and files may be deleted on reboot. It’s convenient — and it’s a classic attack surface. Never run a script from /tmp that you didn’t put there yourself, and never store secrets there.
The Virtual Directories: /proc and /sys
/proc and /sys aren’t real files on disk — they’re windows into the running kernel. /proc shows live process information (each process gets a numbered directory), and /sys exposes hardware and kernel settings. You can read them to learn what the system is doing right now, which makes them invaluable for troubleshooting — and for attackers doing reconnaissance, which is why some hardened systems restrict access to them.
The Quick Reference
- /home — User files — the user can write
- /etc — System configuration — root only
- /var/log — Logs — root / system services
- /usr/bin — Programs — root only
- /tmp — Temporary files — everyone
- /proc, /sys — Live kernel info — nobody (virtual)
Learn this map and the Linux command line stops feeling like a maze. Next time a tutorial says “check the logs” or “edit the config”, you’ll know exactly where to go — and when a directory lets the wrong people write to it, you’ll spot the problem before an attacker does.
Only test systems you own or have written permission to test.



Comments
Post a Comment