File System Hierarchy
Linux Filesystem Hierarchy Standard (FHS). Different from macOS.
Check the list of top level folder by
$ ls /:
/boot: boot loader files
/dev: device files
/etc: configuration files (originally the etcetera directory for files do not belong to other folders)
/home: users' home directories
/media: removable media
/mnt: mounted file systems
/opt: optional application software packages
/proc: virtual filesystem providing process and kernel information as files, e.g.
$ cat /proc/meminfoor
$ cat /proc/cpuinfo. Only available in Linux.
/root: root user's home directory
/run: run-time variable data, will be cleared at the beginning of the boot process
/sbin: essential system binaries, e.g.
/srv: srv=serve, site specific data to be served by the system
/sys: information about devices, drivers, and some kernel features
/tmp: temporary files
/usr: user utilities and applications
/var: variable files
/bin vs /usr/bin
/sbin- Binaries needed for booting, low-level system repair, or maintenance (run level 1 or S)
/bin- Binaries needed for normal/standard system functioning at any run level.
/usr/bin- Application/distribution binaries meant to be accessed by locally logged in users.
/usr/sbin- Application/distribution binaries that support or configure stuff in
/usr/share/bin- Application/distribution binaries or scripts meant to be accesed via the web, i.e. Apache web applications.
/usr/bin can be on separate disks/partitions,
/bin must be on the same disk as
/usr/bin can be on another disk.
Historically the utilities in the
/sbin directories were used to mount the
usr partition. This job is nowadays done by
initramfs, and splitting the directories therefore no longer serves any purpose.
Recently some Linux distros are merging
/usr/bin and relatedly
/usr/lib. Sometimes also
/usr/bin (Arch Linux). So
/usr is expected to be available at the same time as
Scattering utilities over different directories is no longer necessary and storing them all in
/usr/bin simplifies the file system hierarchy.
Check if your system symlinked
$ ls -l /bin lrwxrwxrwx 1 root root /bin -> usr/bin
H to actually see the content of the
ls -lH /bin
/var and /run
/var: contains files to which the system writes data during the course of its operation.
/var/cache(contains cached data from application programs),
/var/games(contains variable data relating to games in /usr),
/var/lib(contains dynamic data libraries and files),
/var/lock(contains lock files created by programs to indicate that they are using a particular file or device),
/var/log(contains log files),
/var/run(contains PIDs and other system information that is valid until the system is booted again) and
/var/spool(contains mail, news and printer queues).
/var/run, will be cleared at the beginning of the boot process.
/run/user/$uid: created by
systemd, local to the system, only accessible by the target user, the same as
/usr vs /usr/local
/usr is for software built elsewhere and then installed on the machine (mostly from your distributions package management system)
/usr/local is for software built locally
FHS requires the Linux kernel image to be located in either