The Linux file system is structured in a hierarchical format, starting from the root directory /
and branching into subdirectories. Each directory has a specific purpose, and understanding these can help you navigate and manage a Linux system more effectively.
/
The root directory is the top-level directory in the Linux file system hierarchy. All other directories and files are nested within this root directory.
/
/bin
- Essential User BinariesContains essential command binaries (executables) needed for single-user mode and for all users. These commands are required for the system to boot and function correctly.
ls
, cp
, mv
, bash
/sbin
- System BinariesHolds essential system binaries that are typically used by the system administrator. These binaries are essential for system maintenance and repair.
fsck
, reboot
, shutdown
, ifconfig
/etc
- Configuration FilesContains all the system-wide configuration files and shell scripts that are used to boot and initialize system settings.
/etc/passwd
(user account information), /etc/fstab
(file system mount points), /etc/hosts
(hostname to IP mappings)/home
- User Home DirectoriesHolds the home directories of all users. Each user has a subdirectory under /home
where their personal files, configurations, and settings are stored.
/home/username
(home directory for the user username
)/root
- Root User’s Home DirectoryThe home directory of the root user (the superuser). It is separate from the /home
directory to ensure the root user’s files are isolated for security and system integrity.
/root
/lib
- Essential Shared LibrariesContains essential shared libraries and kernel modules required for the binaries in /bin
and /sbin
.
libc.so
, libdl.so
/usr
- User Binaries and Read-Only DataStands for “Unix System Resources” and contains user utilities and applications. This directory is further subdivided to organize its contents.
/usr/bin
: Non-essential command binaries for all users (e.g., gcc
, make
)/usr/sbin
: Non-essential system binaries for the superuser (e.g., apache2
, vsftpd
)/usr/lib
: Libraries for /usr/bin
and /usr/sbin
/usr/share
: Architecture-independent data (e.g., documentation, icons, default configurations)/var
- Variable FilesContains variable data files. This includes files that are expected to grow over time, such as logs, databases, cache, and spool files.
/var/log
: Log files (e.g., syslog
, dmesg
)/var/spool
: Spool directories for tasks like printing and mail/var/tmp
: Temporary files preserved between reboots/tmp
- Temporary FilesHolds temporary files created by system and user processes. Files in /tmp
are often deleted on system reboot.
/dev
- Device FilesContains device files that represent hardware devices. These are special files that allow software to interact with hardware devices like disks, terminals, and printers.
/dev/sda
(first hard drive), /dev/tty
(terminals), /dev/null
(null device)/mnt
- Mount DirectoryA generic mount point under which temporary file systems can be mounted. Often used for mounting external storage devices like USB drives.
/mnt/usb
/media
- Removable MediaContains subdirectories for mounting removable media such as USB drives, CD-ROMs, and DVDs.
/media/cdrom
/opt
- Optional PackagesUsed for installing additional software packages that are not part of the default Linux distribution. Often contains commercial software.
/opt/mysoftware
/srv
- Service DataHolds data for services provided by the system, such as web and FTP servers.
/srv/www
(web server data), /srv/ftp
(FTP server data)/proc
- Process InformationA virtual file system that provides a mechanism to access process information and kernel information. It contains a hierarchy of special files representing the current state of the kernel.
/proc/cpuinfo
(CPU information), /proc/meminfo
(memory information)/sys
- System InformationAnother virtual file system similar to /proc
that exposes information about the system and allows interaction with the kernel.
/sys/class
(device classes), /sys/block
(block devices)/run
- Runtime DataContains transient runtime data since the last boot. It is used for storing data that should not persist across reboots.
/run/lock
(lock files), /run/user
(user-specific runtime data)/boot
- Boot Loader FilesContains files related to the boot loader and kernel. These are essential for the system to boot.
vmlinuz
(kernel image), initrd.img
(initial RAM disk)/lost+found
- Recovered FilesA directory used by the fsck
(file system check) utility for recovering lost files. It exists on every partition with a file system.
/lost+found
(contains recovered file fragments)The Linux file system hierarchy is designed to keep the system organized and efficient. Each directory has a specific role, ensuring that files are systematically categorized based on their function and usage. This structure allows users and system administrators to easily locate and manage files and ensures that the operating system operates smoothly.
/bin
, /sbin
, and /lib
to ensure they are available during the boot process and in single-user mode./home
, ensuring each user’s data is isolated and protected./etc
and logs in /var/log
help manage and troubleshoot the system effectively./dev
and /sys
directories provide an interface to hardware devices, allowing the kernel and user space programs to interact with the hardware./tmp
and variable data in /var
ensure that transient and growing data is separated from static system files.