The Filesystem Hierachy Standard is the official convention that defines the Directory structure and contents in Linux distributions and other UNIX-like operating systems. It is maintained by the Linux Foundation.
UsrMerge
Historically the root level and usr level directories were separate, due to Storage-imposed space limitations meaning that root and usr were separate Hard Disks. However, we no longer physically separate them, because the space constraint no longer exists, and because the separation causes confusion. Merging the two makes snapshotting and atomic updates easier.
In practice, the merging just means that every root level instance of a directory like bin is Symlinked to its usr equivalent.
Root
/is the root/trunk/base/head of the filesystem, within which everything else lives.
Home
/homeis where user owned directories live, e.g./home/alice,/home/bob/rootis the home directory equivalent for the Root User
Binaries
bincontains general purpose binaries that everyone can usesbincontains binaries that only the Root User should be using, i.e. “System Binaries”
| Directory | Binaries | System Binaries | Purpose |
|---|---|---|---|
/ | /bin | /sbin | Bare minimum |
/usr | /usr/bin | /usr/sbin | Standard. Package Manager. |
/usr/local | /usr/local/bin | /usr/local/sbin | Manually installed. |
| See [[#usrmerge | UsrMerge]], i.e. bin -> usr/bin, sbin -> usr/sbin |
Libraries
libcontains 32 bit libarieslib64contains 64 bit libaries
| Directory | 32 bit | 64 bit | Purpose |
|---|---|---|---|
/ | /lib | /lib64 | Bare minimum |
/usr | /usr/lib | /usr/lib64 | Standard. Package Manager. |
/usr/local | /usr/local/lib | /usr/local/lib64 | Manually installed. |
| See [[#usrmerge | UsrMerge]], i.e. lib -> usr/lib, lib64 -> usr/lib64 |
Optional
/optis for manually installed optional software.- e.g.
/usr/bin/google-chrome -> /opt/google/chrome/google-chrome
- e.g.
Hardware
/devcontains handles to hardware via files- e.g. hard drive might be at
/dev/sda - e.g. webcam might be at
/dev/video0
- e.g. hard drive might be at
/mediaor/mntare where the system automatically “mounts” removable media devices into the filesystem
Configuration
/etcentirely contains files relevant to system configuration. “Et-cetera”./etc/passwdis a list of all User accounts; usernames, user ids, group ids, home directory paths, and the type of shell they use/etc/shadowhas encrypted passwords and account expiration information/etc/sudoersdefines which users and groups are allowed to runn commands as root using sudo/etc/hostnameoneliner file that contains the hostname of the machine/etc/os-releaseis basically the ID for the machine/etc/fstabis the “Filesystem Table” that tells the OS which hard drives, partitions, or networks shares to automatically mount upon boot/etc/hostsis a local address book that maps IPs to hostnames. A DNS cache.
$HOME/.config
Temporary
/tmpis where “Temporary”/Ephemeral data gets stored. It is automatically wiped./runis a temporary storage area for system data that has accumulated during the runtime of the OS since the last boot. It stores PIDs and Sockets. It also holds information about logged-in users and temporary network settings.
Magic
/procis a window into the Linux Kernel that essentially acts as a File-driven API for either querying information from the kernel, or requesting the kernel to do something. Instead of some special command to query some information from the kernel, you can simply just read a particular file in/procto get that information. Because/procis magic, the inodes located there are posers! They are ephermeral, exist only in RAM, and are generated on-demand./sysstores a structures view of every piece of hardware connected to the machine. Unlike,/proc,/sysalows you the change thing by writing the files. Unlike/proc/sys,/sysis for hardware interaction, whereas the former is for kernel interaction.
Misc
/varis used for holding persistent data. “Variable”./var/logholds logs/var/libcontains persistent state data, e.g. database tables or container volumes/var/cachecontains cached data, e.g. package manage might cache data here