Linux file structure
The Linux file system follows a hierarchical structure, often referred to as the Linux directory structure or Filesystem Hierarchy Standard (FHS). It organizes files and directories into a tree-like structure, starting from the root directory (/
). Here's a breakdown of the typical Linux file structure with descriptions of common directories and options associated with them.
1. /
(Root Directory)
- Description: The root directory is the top-level directory in the file system. All other directories are subdirectories of this root directory.
- Example:
2. /bin
- Description: Contains essential command binaries (executables) needed for the system to function in single-user mode. These are required for basic system functionality, such as
ls
,cp
,cat
, etc. - Example:
3. /boot
- Description: Holds files required for booting the system, such as the Linux kernel and bootloader configuration files.
- Example:
4. /dev
- Description: Contains device files that represent hardware devices (like hard drives, USB devices, and terminals). These files provide an interface for interacting with hardware.
- Example:
5. /etc
- Description: Contains system configuration files and scripts used by various system programs. This is where the main configuration files for system services reside.
- Example:
6. /home
- Description: Contains the personal directories of all users on the system. For example,
/home/john
would be the home directory for the userjohn
. - Example:
7. /lib
- Description: Contains essential shared libraries required by system binaries in
/bin
and/sbin
. These libraries are necessary for system programs to function. - Example:
8. /media
- Description: This directory is used to mount removable media like CDs, DVDs, and USB drives. It provides a location where removable media can be accessed.
- Example:
9. /mnt
- Description: A temporary mount point for mounting filesystems, usually used for mounting storage devices during system maintenance or administration.
- Example:
10. /opt
- Description: Contains optional software packages that are not part of the default system installation. These are often third-party applications installed manually.
- Example:
11. /proc
- Description: A virtual file system that provides information about system processes and kernel parameters. The files in this directory do not exist on disk but are created dynamically by the kernel.
- Example:
12. /root
- Description: The home directory for the system's root user (superuser). This is different from
/home
, which contains regular users' home directories. - Example:
13. /run
- Description: Contains runtime data for processes started since the last boot, including system information and PID files for services.
- Example:
14. /sbin
- Description: Contains system binaries (executables) used for system administration tasks, such as
fsck
,mount
, andshutdown
. These programs are typically for the root user. - Example:
15. /srv
- Description: Contains data for services provided by the system, such as web or FTP servers.
- Example:
16. /sys
- Description: A virtual file system providing information about devices, kernel parameters, and more. It is used for kernel and device management.
- Example:
17. /tmp
- Description: A directory for temporary files used by applications or the system. Files in
/tmp
are often cleared upon reboot or after a certain period. - Example:
18. /usr
- Description: Contains system-wide read-only data and programs. It holds most user utilities and applications, as well as libraries and documentation.
/usr/bin/
: Essential user command binaries/usr/lib/
: Shared libraries/usr/share/
: Architecture-independent data, such as documentation
- Example:
19. /var
- Description: Contains variable files, such as logs, caches, and databases. It is meant for files that are expected to grow or change during normal system operation.
/var/log/
: Log files/var/lib/
: State information for applications/var/spool/
: Mail, print queues, etc.
- Example:
Summary of Common Directories
Directory | Description |
---|---|
/ | Root directory, the base of the file system |
/bin | Essential binaries for system operation |
/boot | Bootloader and kernel files |
/dev | Device files |
/etc | System-wide configuration files |
/home | User home directories |
/lib | Essential system libraries |
/media | Mount points for removable media |
/mnt | Temporary mount points |
/opt | Optional software packages |
/proc | Virtual file system for system processes |
/root | Root user's home directory |
/run | Runtime system information |
/sbin | System binaries for administration |
/srv | Data for services |
/sys | Kernel and device information |
/tmp | Temporary files |
/usr | User programs and data |
/var | Variable data, such as logs and caches |
This file structure ensures consistency and organization, allowing for easier system maintenance and management.