Skip to main content

Filesystem

The filesystem in Linux is a system of organizing and storing files on a storage device. It provides a hierarchical structure, starting from the root directory ("/"), and allows users and applications to efficiently read, write, and manage files. This system is essential for data management, enabling access control, file permissions, and efficient data retrieval.

📖Bookmarks

LPI Learning Material 101 - Topic 102.1 (Pages 52 - 64)

LPI Learning Material 101 - Topic 104 (Pages 403 - 542)

Filesystem Hierarchy

A Debian system is organized along the Filesystem Hierarchy Standard (FHS). This standard defines the purpose of each directory. For instance, the top-level directories are described as follows:

/bin/: basic programs;

/boot/: Linux kernel and other files required for its early boot process;

/dev/: device files;

/etc/: configuration files;

/home/: user's personal files;

/lib/: basic libraries;

/media/: mount points for removable devices (CD-ROM, USB keys and so on);

/mnt/: temporary mount point;

/opt/: extra applications provided by third parties;

/root/: administrator's (root's) personal files;

/run/: volatile runtime data that does not persist across reboots;

/sbin/: system programs;

/srv/: data used by servers hosted on this system;

/tmp/: temporary files; this directory is often emptied at boot;

/usr/: applications; this directory is further subdivided into bin, sbin, lib (according to the same logic as in the root directory). Furthermore, /usr/share/ contains architecture-independent data. /usr/local/ is meant to be used by the administrator for installing applications manually without overwriting files handled by the packaging system (dpkg).

/var/: variable data handled by daemons. This includes log files, queues, spools, caches and so on.

/proc/ and /sys/ are specific to the Linux kernel (and not part of the FHS). They are used by the kernel for exporting data to user space (see Section B.3.4, “The User Space” and Section B.5, “The User Space” for explanations about this concept).

Note that many modern distributions, Debian included, are shipping /bin, /sbin and /lib as symlinks to the corresponding directories below /usr so that all programs and libraries are available in a single tree. It makes it easier to protect the integrity of the system files, and to share those system files among multiple containers, etc.

Commands for filesystem management

There are multiple commands and tools for inspecting and managing filesystem. Most common are fdisk, df and mount. And configuration of system mountpoints can be found in /etc/fstab.