Hardware

How is the file system structured in gnu / linux?

Table of contents:

Anonim

Surely, many of you, like me, learned to use computers with some version of Windows and it is likely that one of the first things they became familiar with was how to manage all the information they kept stored in it or some removable media connected to the pc. That is, to perform tasks such as copying, pasting, moving or locating our files. For this reason, this time we want to show you how the file system is structured in Linux / GNU. It is certainly not necessary to know it 100%, but it would be very useful to have an idea of ​​the hierarchy of the files.

Index of contents

How is the file system structured in GNU / Linux?

Linux systems reside under a hierarchical tree of files, much like how Unix systems are structured. In the beginning, this hierarchical tree of directories and files was not under any standard, that is, there were variations between one distribution and another. It was this that motivated a group of people to develop, in 1993, what is known as the Filesystem Hierarchy Standard (FHS) or in Spanish File System Hierarchy Standard.

FHS

The FHS is defined as the standard that establishes and provides the details of the names, contents, locations and permissions of files and directories, in other words, it is the set of rules that determine a common structuring of files and directories on Linux systems. This standard is nothing more than a guiding document, which can be consulted by manufacturers and applied when creating a new distribution.

It is important to clarify that a manufacturer can decide whether to apply it or not. The advantage of integrating it with your Linux system is that it will make your environment much more compatible with the rest of the Linux distributions. Another point to highlight is that the standard allows some flexibility, therefore, there are certain freedoms when applying the rules and from there the fact that there are certain slightly slight differences between different distributions.

FHS Main Objectives

  • Expose a hierarchical file system consistently and uniformly. Provide ease in the development of software, since it will allow easy prediction and identification of installed files and directories. Give the user ease in predicting the location of files and directories on their computer.

As we see, the main focus of the FHS is to create operating systems with the most compatible structures possible. This will provide a better experience for ordinary users, since they will be able to understand the meaning of each element within the system and easily locate it. On the other hand, the FHS itself shows what are the types of files that can be seen in the system structure:

Shareable and non-shareable files : The former are files belonging to a computer and the latter are files that can be shared between different computers. For example:

  • Shareable files: the contents in / var / www / html (which is the default DocumentRoot of the Apache Web server. Where the welcome index.html is initially stored). Non-shareable files: the contents in / boot / grub / (Subdirectory where the GRUB boot loader files are located).

Static and Variable Files: Static files are those that require the interaction of the system administrator to change their state. And the variables those that can change without such interaction. To help you understand this better, let's look at an example. We have the system log files (logs), these are of the variable type, since they are constantly modified without the intervention of the administrator, since they are messages generated by the system kernel. While the other files where sensitive information such as user accounts, settings or passwords are stored, they are of the static type.

Take a look at: Linux Commands: Know and manipulate the system

Access to different file systems

Knowing this classification of file types, we must also know that in Linux everything is a file. Both hardware and software are storing as a text file and it is from there that the concept of "mounting" or "unmounting" a device is born. That is, its logical structure is independent of the hardware structure, therefore, it does not depend on whether the computer has 1, 3 or 5 hard drives to create the c: \, e: \ ok: \ drives.

The entire Linux system originates from the root or roo t, represented by / and all other accessible files in the operating system are located under that directory. For example, we want to access a CDROM. This is mounted to the system as a subdirectory. In that subdirectory the content of the device will be located when it is mounted and we will not find anything otherwise. To get the list of devices mounted on the system, we simply use the mount command in the console. It is important that this concept is clear to know how Linux works.

As I mentioned, we can also access hardware devices with this mechanism, but these files are binary, that is, they are only interpreted by Linux. Therefore, if we make any edition we run the risk of leaving the system unstable and even unusable. In short, access to them is not an option unless you are completely sure of what we do. Now that we know on a theoretical level what its structure is like. Let's see how is the application of the FHS in real life?

File system structuring in Linux according to FHS

directory Description
/ Primary hierarchy , called root or root, main directory, container of absolutely the entire file system in Linux.
/ bin / It contains the essential command binaries, so that they are available either for a single session or for multi-users. They include, for example, ls, cp, cat, mkdir, rm, among others
/ boot / System startup.
/ dev / Contains the accesses to the devices. Both hardware or virtual.
/etc/ This includes the system configuration files. There has been controversy over the meaning of its name, but more recent interpretations refer to it as "Editable Text Settings".
/ etc / opt / Configuration files of the programs located inside the / opt directory.
/ etc / X11 / X Window System version 11 configuration files.
/ etc / sgml / SGML configuration files.
/ etc / xml / XML configuration files.
/home/ Contains the working directories of all users, except the superuser (administrator, root). Contains saved files, personal settings, etc. It is often installed on a separate disk or partition . Each user has their own directory within this folder.
/ lib / All the fundamental shared libraries of the installed programs are located, including those used by the kernel.
/half/ Contains mount points for removable storage media.
/ mnt / It is similar to / media, but normally used by users. In order to "mount" for example hard drives and temporary partitions.
/ opt / Contains information about applications that do not save configuration options in this directory, that is, users share the application but not its configuration options.
/ proc / Contains files that document the core and status of your processes at specific times.
/ root / Main directory of the root user. It is like the / home but for the system superuser (administrator).
/ sbin / Executables or binaries essential for operation, exclusive commands and programs of the system administrator or users who have permissions to use them.
/ srv / Contains the data served by the system.
/ tmp / Contains temporary files.
/ usr / secondary hierarchy of user data; It contains most of the utilities that are multi-user purpose but that are nevertheless read-only. This folder can even be shared with other local network users.
/ usr / bin / Non-administrative binary commands for all users.
/ usr / include / Standard include files.
/ usr / lib / Set of shared libraries or binaries. There are never two identical libraries on the same system, which optimizes memory usage and provides greater order.
/ usr / sbin / Binaries that are not essential; for example, daemons to have multiple network services.
/ usr / share / Contains data that is shared but is independent of architecture.
/ usr / src / Contains the source codes of some applications.
/ usr / X11R6 / Directory related to the graphic environment.
/ usr / local / Tertiary hierarchy for local data, that is, specific to this host.
/ var / Contains system variable files such as logs, databases, email.
/ var / cache / Similar to / tmp, it contains the cache memory of some applications.
/ var / crash / Contains information regarding errors or system crashes.
/ var / games / It is a directory that is not essential and its purpose is to store information regarding system games.
/ var / lock / Files that have the status of the resources in use are located.
/ var / log / Log files .
/ var / mail / Archives of user messages, similar emails.
/ var / opt / Contains data that can be variables in the / opt directory.
/ var / run / Access to information since the last system startup. For example, users currently connected, or demons running.
/ var / spool / Includes tasks that are waiting to process. For example, unread emails or print queues.
/ var / spool / mail / Location of emails from disapproved users.
/ var / tmp / It contains temporary files, its difference with / tmp is the fact that it is not deleted when rebooting the system.
WE RECOMMEND YOU How to Install Ubuntu in Windows 10 step by step

You may be interested in reading: What you need to know about root, su and sudo in Linux

Permissions

To close the topic, in Linux, as well as in other Unix systems, a permission policy is maintained on the files. In order to control access, what can they do about it and who can do it. Permissions are identified by letters and are established in this way:

  • a: permission to read the file w: permission to write the file x: permission to execute the file s: permission to make changes to the owner of the file.

Likewise, each permission in Linux can be applied: for file owners, the group that the owner belongs to, or the rest of the users. Which allows this security mechanism to work perfectly in work groups with different responsibilities (multi-users).

Hardware

Editor's choice

Back to top button