Files
amILearningEnough/docs/resources/linux/unix-file-system-hierarachy.md
2025-07-12 23:59:52 +09:00

94 lines
5.5 KiB
Markdown

# Unix File System Hierarchy
The Unix file system hierarchy is a standardized directory structure that organizes the files and directories on a Unix-based operating system. This hierarchical structure ensures consistency and predictability across different Unix-like systems, making it easier for users and applications to interact with the file system.
## The Root Directory (`/`)
The root directory, denoted by the forward slash (`/`), is the topmost directory in the Unix file system hierarchy. It serves as the starting point for all other directories and files.
## Essential User Command Binaries (`/bin`)
The `/bin` directory contains essential user command binaries, which are executable files for common user-level commands, such as `bash`, `cat`, `chmod`, `date`, `echo`, `grep`, `gzip`, `hostname`, `kill`, `less`, `ls`, `mkdir`, `mount`, `mv`, `nano`, `open`, `ping`, `pwd`, `rm`, `sh`, `su`, `tar`, `touch`, and `umount`.
## System Configuration Files (`/etc`)
The `/etc` directory is the home for system configuration files, including `crontab` (scheduled tasks), `cups` (printing system), `fonts` (font files), `host.conf` (host name resolution configuration), `hostname` (system host name), `hosts` (hosts file for name resolution), `hosts.allow` and `hosts.deny` (network access control), `init` (system initialization), `issue` (message of the day), `machine-id` (unique machine ID), `mtab` (mounted file systems), `mtools.conf` (configuration for MTOOLS), `nanorc` (nano text editor configuration), `networks` (network name resolution), `passwd` (user account information), `profile` (system-wide environment and startup scripts), `protocols` (network protocols), `resolv.conf` (DNS resolver configuration), `rpc` (Remote Procedure Call configuration), `securetty` (secure TTY list), `services` (network services), `shells` (list of available shells), and `timezone` (system timezone information).
## Essential System Binaries (`/sbin`)
The `/sbin` directory contains essential system binaries, which are executable files for system administration commands, such as `fdisk` (partition management), `fsck` (file system check and repair), `getty` (login process), `halt` (system shutdown), `ifconfig` (network interface configuration), `init` (system initialization), `mkfs` (file system creation), `mkswap` (swap space creation), `reboot` (system reboot), and `route` (network routing configuration).
## Read-Only User Application Support Data & Binaries (`/usr`)
The `/usr` directory is the home for read-only user application support data and binaries, including:
- `/usr/bin`: "most user commands"
- `/usr/include`: "standard include files for 'C' code"
- `/usr/lib`: "obj, bin, lib files for coding & packages"
- `/usr/local`: "local software" (including `/usr/local/bin`, `/usr/local/lib`, `/usr/local/man`, `/usr/local/sbin`, and `/usr/local/share`)
- `/usr/share`: "static data sharable across all architectures"
- `/usr/share/man`: "manual pages"
## Variable Data Files (`/var`)
The `/var` directory is the home for variable data files, including:
- `/var/cache`: "application cache data"
- `/var/lib`: "data modified as programs run"
- `/var/lock`: "lock files to track resources in use"
- `/var/log`: "log files"
- `/var/opt`: "variable data for optional packages"
- `/var/spool`: "tasks waiting to be processed"
- `/var/tmp`: "temporary files saved between reboots"
## Device Files (`/dev`)
The `/dev` directory contains device files, which represent physical or virtual devices on the system, such as `/dev/null`, `/dev/zero`, and `/dev/random`.
## Home Directories (`/home`)
The `/home` directory is the location for user home directories, where users can store their personal files and configurations.
## Mount Points (`/mnt`)
The `/mnt` directory is used as a mount point for temporary file systems, typically used for mounting external storage devices or network file systems.
## Process & Kernel Information Files (`/proc`)
The `/proc` directory is a virtual file system that provides access to information about running processes and the kernel, such as CPU, memory, and other system resources.
## Root User Home Directory (`/root`)
The `/root` directory is the home directory for the root user, the superuser with full administrative privileges.
## Temporary Files (`/tmp`)
The `/tmp` directory is used for storing temporary files that are deleted between system reboots.
## System Libraries & Kernel Modules (`/lib`)
The `/lib` directory contains system libraries and kernel modules, which are essential for the proper functioning of the operating system.
## Optional Software Applications (`/opt`)
The `/opt` directory is used for installing optional software applications, which are not part of the core system.
## Mount Points for Temporary Filesystems (`/run`)
The `/run` directory is used as a mount point for temporary file systems that are created and destroyed between system boots.
## System Boot & Init Information (`/boot`)
The `/boot` directory contains files essential for booting the operating system, such as the kernel image, initramfs, and boot loader configuration.
## System Logs (`/var/log`)
The `/var/log` directory is the location for system log files, which record various events and activities on the system.
## Spool Directories (`/var/spool`)
The `/var/spool` directory is used for storing tasks that are waiting to be processed, such as print jobs, mail, and cron jobs.
## Temporary Files (`/var/tmp`)
The `/var/tmp` directory is used for storing temporary files that persist across system reboots, unlike the `/tmp` directory.