Directory layout: what each folder is for
Linux has a single directory tree with everything under the root /. There are no drive letters like C: or D:; USB sticks and extra disks are mounted onto a directory in the tree. What each directory is for is defined by the FHS (Filesystem Hierarchy Standard), which most distributions follow.
Try ls / and tree -L 1 / in the simulator.
Top-level directories
| Directory | Name | Purpose |
|---|---|---|
/bin | binaries | Essential commands for all users, e.g. ls, cp, cat |
/sbin | system binaries | System administration commands, usually needing root, e.g. fdisk, reboot |
/boot | boot | Files needed to start the system: the kernel (vmlinuz), initramfs, the GRUB boot loader |
/dev | devices | Device files. A disk is /dev/sda; /dev/null is a "black hole" that discards whatever is written to it |
/etc | Originally "et cetera" (everything else); often read today as "editable text configuration" | System-wide configuration files, e.g. /etc/passwd, /etc/hosts, /etc/nginx/ |
/home | home | Home directories of regular users, e.g. /home/alice; ~ means your own |
/root | root | Home directory of the superuser root (not under /home) |
/lib, /lib64 | libraries | Shared libraries (like Windows .dll files) for programs in /bin and /sbin, plus kernel modules |
/media | media | Removable media mounted automatically: USB sticks, CDs |
/mnt | mount | Where an administrator mounts file systems temporarily |
/opt | optional | Self-contained third-party software, e.g. /opt/google/chrome |
/proc | processes | Virtual file system generated live by the kernel: one directory per process (/proc/1234), plus /proc/cpuinfo, /proc/meminfo |
/run | run time | Runtime data since boot, such as PID files and sockets; cleared on reboot |
/srv | services | Data for services this machine provides, e.g. websites, FTP files |
/sys | system | Virtual file system to inspect and tune the kernel, hardware and drivers |
/tmp | temporary | Temporary files, writable by everyone, usually cleared on reboot |
/usr | Originally user (home directories); often explained as "Unix System Resources" | Most installed software and read-only data: /usr/bin, /usr/lib, /usr/share |
/var | variable | Data that changes while the system runs: logs in /var/log, caches in /var/cache, mail, databases |
Inside /usr
| Directory | Purpose |
|---|---|
/usr/bin | Where almost all user commands live |
/usr/sbin | Non-essential administration commands |
/usr/lib | Libraries |
/usr/local | Software the administrator builds or installs by hand, safe from the package manager; has its own bin, lib … |
/usr/share | Architecture-independent data: documentation, man pages (/usr/share/man), icons |
/usr/include | C/C++ header files |
Did you know? Many recent distributions have "merged /usr": /bin, /sbin and /lib are just symbolic links to /usr/bin, /usr/sbin and /usr/lib. Look for the -> arrows in ls -l /.
Where to look
- Configuration problem? Start with the program's files in
/etc. - A program is failing? Check the logs in
/var/log, or use journalctl. - Your own files belong in
~(your home); no root needed. - Quick experiments can go in
/tmp. - Software you install yourself goes in
/optor/usr/local.