FHS rules govern the layout of Linux system directories - Part 1

Hello.
I'm Mandai, the Wild team member in charge of development.

When you first start using Linux, you might intuitively remember where Apache's config file is located and have a vague understanding of it. However, there are proper reasons behind
the structure of Linux system directories, the names of each directory, and their placement. I thought that knowing these reasons would make things much easier to understand, so I'm writing this article to explain FHS (Filesystem Directory Structure).

What is FHS?

FHS stands for "File Hierarchy Standard" and defines the standard for Linux file structure

Knowing this before entering a Linux console can improve your work efficiency by helping you understand why a file is there and pinpoint the location of the file you want to see.
Since this FHS (File System Handbook) is used in most Linux distributions, there may be slight differences in interpretation, but the overall structure is generally similar.

The FHS also has different versions, and version 3.0 is currently in development.
Since its release date was May 18, 2015, its content will likely change over time.

 

Configuration under the root directory

The original text of the latest FHS 3.0the FHS Referenced Specifications, but since it's in English, I'll focus on explaining the basic parts.

 

/bin

This is the command storage location for all users.
Creating subdirectories within this directory is prohibited. It
contains 33 essential commands such as ls, cat, ps, and mkdir, plus 9 optional commands.
These are all indeed basic commands that are considered essential.

The listsection 3.4. /bin: Essential user command binaries (for use by all users).

This list includes `more` but not `less`.
Therefore, it's surprising that the `less` command isn't necessarily installed by default (a `less` user's opinion).

 

/boot

This directory contains files related to the boot loader and inetd. It
's often located in the hard drive's master boot record and appears to be used before the OS boots.

 

/dev

This is where device files are stored.
It contains files related to null and tty, which you'll likely use most often.
These files are used to access various devices.

 

/etc

The "etc" stands for "etcetera" (other).
In the very early days of Unix, it seems to have been a place for files that couldn't be clearly categorized, but now it's the location for static configuration files, and executable binary files are not allowed there.

 

/home

This directory is used to store each user's home directory.
How a user uses their home directory is up to them; it may simply be a place to store personal files, or it may contain files intended for internet access, such as public_html, under the apache user's home directory.

Note that installing /home is optional, so it seems that there should be no problems with the system if it is not installed

 

/lib

This is where shared libraries and kernel modules are located.
When I looked at /lib on my CentOS 7 system, I found that this directory itself was a symbolic link to /usr/lib.

In this way, thanks to symbolic links, Linux can keep up with FHS version updates without affecting existing systems

 

/lib<qual>

<qual>の部分には、システムのビット数が入ります。
you place 64-bit environment-specific shared libraries and the like.
directory is where
In fact, even when looking at Linux servers in operation, the /lib64 directory is sometimes sparse or empty, so its usage is tricky.

Troubleshooting when VirtualBox shared folders can no longer be mounted |There are also cases described in Beyond Co., Ltd., so caution is advised.

 

/media

Stores the mount point for removable media

However, there are several patterns for mount points for removable media. They can be /cdrom directly under the root directory, /mnt itself can be the mount point, or they can be in the form of /mnt/cdrom, etc.
FHS considers it undesirable to create a mount point directly under the root directory because a subdirectory will be created every time it is mounted.

Also, it seems that it has become common recently to use /mnt or below as a mount point, but on some older systems, /mnt itself may be used as a temporary mount point, which can lead to configuration conflicts, so it is better to use /media

 

/mnt

In the past, /mnt was a very common mount point, but FHS3.0 advises that it should only be used in a very limited and passive way by system administrators to temporarily use file systems

Since /mnt is treated as temporary, any file system mounted there should not affect the operation of any programs that are executed

 

/opt

The /opt directory is provided as the installation location for additional software and packages.
You can use `/opt/[software package name]`, orLANANAplace a directory with the software name inside a directory with the provider name registered in

Some users install their own compiled software here.
This itself doesn't seem to be a problem from an FHS perspective, but there's a possibility of conflicts with names registered in LANANA, so you should be careful to use unique names.

 

/root

This is the root user's home directory.
Be careful when placing files that other users might need to execute within this directory, as they may not have sufficient permissions to run.

/root does not seem to be a required directory, but if it does not exist, "/" will be treated as the root home directory, which can be confusing, so it is probably better to set it up

 

/run

This directory stores system information from the time of boot. It
primarily contains PID files, lock files, and socket files.

 

/sbin

sbin stands for System binaries and contains utility commands for system administrators.
The commands found here are those provided by the distribution; any additional tools added by the system administrator for administrative purposes should be added under /usr/sbin.

 

/srv

This site is set up to make it easier to find and manage data files for services running on the server in a consolidated manner

However, since there is no specific decision on how to create the file structure using /srv, it is empty on CentOS7

One way is to create a directory based on the protocol, place directories with the names of services that use that protocol in subdirectories, and layout the directory so that configuration files, management scripts, etc. are placed there

 

/tmp

This is everyone's favorite temporary directory.
When you restart, /tmp will be empty, while /var/tmp will retain its information.

This is getting long so I'll continue in the second half

That's all

If you found this article helpful,please give it a "Like"!
14
Loading...
14 votes, average: 1.00 / 114
16,179
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but thankfully I'm also given the opportunity to work on various other tasks, including marketing.
My image rights within Beyond are treated as CC0.