November 4, 2023

The Linux Filesystem. Hierarchy and organization.

Understand the directory organization and hierarchy of a Linux filesystem

The Linux Filesystem

Linux, the epitome of customization and efficiency in the world of operating systems, is characterized by its robust filesystem structure. With its versatility and scalability, it is suitable for different uses, from embedded devices to supercomputers. Despite the variety of Linux distributions available, the basic filesystem structure remains remarkably constant, thus ensuring common ground for users and industry professionals.

This article offers an in-depth look at each directory of a classic Linux filesystem, allowing readers to better understand the organization and hierarchy that form the backbone of every Linux distribution.

Linux filesystems

It is essential for anyone working in the IT sector, and in particular in the hosting and systems engineering sector, to have a solid understanding of this aspect, which is crucial for optimizing the performance and effective management of Linux-based systems.

Understand directory organization and hierarchy in a classic Linux filesystem

The Linux filesystem is more than just a place where files reside; it is a structured environment that follows a stringent logic, essential for maintaining order and efficiency of the system. Each directory has a well-defined purpose and contains certain types of files. Here is an overview of the most common directories and their functions:

  1. / – Root Directory The root directory, identified only by the forward slash (“/”), plays a crucial role as it represents the main level of the Linux filesystem tree structure. This directory contains subdirectories and files that form the backbone of the operating system, and is the reference point from which all other directories start. Its integrity and security are essential for the stability and security of the entire system.
  2. / bin – Essential Command Binaries The /bin directory is the repository for executable files that are critical for basic system operations, such as booting, recovery, and maintenance in single-user mode. These executable files include some of the most used tools in Linux, essential for browsing and managing files, and are accessible to all users.
  3. / Boot – System Boot Loader Files /boot contains the critical files for the startup phase of the operating system. These include not only the Linux kernel image, which is essential for booting the system, but also configuration files and boot scripts, such as GRUB, which are the computer's first point of contact during hardware initialization.
  4. / Dev – Device Files The /dev directory is a unique aspect of Unix-like systems, where devices are treated as files. Inside this directory are special files that represent physical devices (such as hard drives and USB devices) and virtual devices (such as sockets and pipes), allowing the system and users to interact with them through standard file operations.
  5. / Etc – Host-specific Configuration Files /etc is the central library of system configuration files. Every service program and startup script draws on this directory for its configurations, ranging from user management, to network services, to system daemons. Changes in this directory can have a significant impact on system operation and security.
  6. / Home – User Home Directories The /home directory is the virtual place where users can store their documents, application configurations and personal data. It serves as a personal workspace for users, offering clear and secure separation of data between different accounts.
  7. / lib – Shared Library Modules The /lib directory contains the shared libraries necessary for the operation of the essential programs located in /bin and /sbin. Libraries are code that can be used by multiple programs at the same time, saving space and resources and allowing for easier updating and maintenance of the software.
  8. /half – Removable Media Files /media serves as a mount point for removable devices, such as CD-ROMs, DVDs, and USB flash drives. The operating system usually creates subdirectories in /media automatically when a device is connected, allowing users to easily access the contents of removable devices.
  9. / Mnt – Temporary Mounted Filesystems Filesystems of various types are temporarily mounted in /mnt, often used by system administrators for manual temporary mounts. It is a kind of workspace for accessing non-permanent filesystems, such as those shared via network or external disks in temporary use.
  10. / Opt – Add-on Application Packages The /opt directory is intended to host additional software and applications that are outside of the Linux distribution's standard package management system. This may include commercial software packages and other third-party applications that do not integrate tightly into the standard filesystem hierarchy.
  11. / Proc – Automatically Generated Files The /proc directory is a distinctive feature of Linux, providing a dynamic view of system execution. This directory does not physically exist on disk but is dynamically generated by the kernel, offering a real-time window into the system and running processes, including metrics such as CPU and memory usage, as well as internal kernel configurations.
  12. / Root – Home Directory for root user The /root directory is the personal space reserved for the root user, which is the top administrative account in the Linux system. This separation from /home ensures that critical administrator files are kept secure and separate from standard user data.
  13. / run – Run Time Program Data /run is designed to contain system information that is needed from system startup until the filesystem is fully loaded and is vital to the boot process and system execution. It includes volatile data such as PIDs of running processes and lock files, which help manage and coordinate startup and interaction between various services.
  14. / sbin – System Binaries The /sbin directory is similar to /bin but contains binaries and programs that are typically run by the system administrator. These tools are essential for system maintenance, diagnostics, and repair, and include commands for filesystem management, hardware monitoring, and other system administration tasks.
  15. / srv – Site-specific Data Served by the System /srv contains data that is served by the system for various services, such as web server data, FTP, and other data transfer protocols. This directory is often used to hold data that is exposed to clients over the network.
  16. / sys – Virtual Directory for System The /sys directory, like /proc, is a virtual view provided by the kernel that exposes information about the system's hardware devices through the sysfs filesystem, allowing administrators to fix and obtain detailed information about the hardware and make certain configurations at the system level.
  17. / Tmp – Temporary Files /tmp is the archive for temporary files used by applications and the operating system. This data is usually intended to be retained only for the duration of a session and is often cleared when the system reboots, providing automatic cleanup and preventing the accumulation of superfluous data.
  18. / Usr – Read-only User Data /usr is one of the largest subdirectories and serves as a repository for user applications, shared libraries, documentation, and source code. Designed to be read-only during normal system operation, /usr provides a vital collection of resources for users and programs.
  19. / var – Variable Files The /var directory is intended to contain files that are subject to frequent changes, such as log files that record system activities, print queue files, pending emails, and other dynamic data. These files often grow without predefined limits, thus requiring careful management of disk space.

These are the foundations that make up the Linux operating system, and a detailed understanding of each of these directories is crucial to managing and maintaining the system. Whether you are a system administrator, developer, or simply an enthusiast, a good understanding of the Linux file system is an invaluable asset.

 

Do you have doubts? Don't know where to start? Contact us!

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.

0256569681

Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

INFORMATION

Managed Server Srl is a leading Italian player in providing advanced GNU/Linux system solutions oriented towards high performance. With a low-cost and predictable subscription model, we ensure that our customers have access to advanced technologies in hosting, dedicated servers and cloud services. In addition to this, we offer systems consultancy on Linux systems and specialized maintenance in DBMS, IT Security, Cloud and much more. We stand out for our expertise in hosting leading Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Joomla, OpenCart and Magento, supported by a high-level support and consultancy service suitable for Public Administration, SMEs and any size.

Red Hat, Inc. owns the rights to Red Hat®, RHEL®, RedHat Linux®, and CentOS®; AlmaLinux™ is a trademark of AlmaLinux OS Foundation; Rocky Linux® is a registered trademark of the Rocky Linux Foundation; SUSE® is a registered trademark of SUSE LLC; Canonical Ltd. owns the rights to Ubuntu®; Software in the Public Interest, Inc. holds the rights to Debian®; Linus Torvalds owns the rights to Linux®; FreeBSD® is a registered trademark of The FreeBSD Foundation; NetBSD® is a registered trademark of The NetBSD Foundation; OpenBSD® is a registered trademark of Theo de Raadt. Oracle Corporation owns the rights to Oracle®, MySQL®, and MyRocks®; Percona® is a registered trademark of Percona LLC; MariaDB® is a registered trademark of MariaDB Corporation Ab; REDIS® is a registered trademark of Redis Labs Ltd. F5 Networks, Inc. owns the rights to NGINX® and NGINX Plus®; Varnish® is a registered trademark of Varnish Software AB. Adobe Inc. holds the rights to Magento®; PrestaShop® is a registered trademark of PrestaShop SA; OpenCart® is a registered trademark of OpenCart Limited. Automattic Inc. owns the rights to WordPress®, WooCommerce®, and JetPack®; Open Source Matters, Inc. owns the rights to Joomla®; Dries Buytaert holds the rights to Drupal®. Amazon Web Services, Inc. holds the rights to AWS®; Google LLC holds the rights to Google Cloud™ and Chrome™; Facebook, Inc. owns the rights to Facebook®; Microsoft Corporation holds the rights to Microsoft®, Azure®, and Internet Explorer®; Mozilla Foundation owns the rights to Firefox®. Apache® is a registered trademark of The Apache Software Foundation; PHP® is a registered trademark of the PHP Group. CloudFlare® is a registered trademark of Cloudflare, Inc.; NETSCOUT® is a registered trademark of NETSCOUT Systems Inc.; ElasticSearch®, LogStash®, and Kibana® are registered trademarks of Elastic NV This site is not affiliated, sponsored, or otherwise associated with any of the entities mentioned above and does not represent any of these entities in any way. All rights to the brands and product names mentioned are the property of their respective copyright holders. Any other trademarks mentioned belong to their registrants. MANAGED SERVER® is a registered trademark at European level by MANAGED SERVER SRL Via Enzo Ferrari, 9 62012 Civitanova Marche (MC) Italy.

Back to top