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

Hello,
I'm Mandai, the Wild Team member of the development team.
When you first start using Linux, you may have a vague idea of where the Apache config is, just memorizing it intuitively. I believe there is a
reason for the structure of Linux system directories, and the names and locations of each directory, and knowing this can make things easier to understand, so I've put together this article summarizing FHS.
What is FHS?
FHS stands for "File Hierarchy Standard" and defines the standard for Linux file structure
Knowing this, when you enter the Linux console, you may be able to understand why a file is there and guess the location of the file you want to see, which may improve your work efficiency.
This FHS is adopted by most Linux distributions, so although there are some differences in interpretation, they are generally structured in a similar way.
FHS also has different versions, and version 3.0 is currently being formulated.
This was published on May 18, 2015, so it seems that the content will change over time.
Configuration under the root directory
The original text of the latest FHS3.0 FHS Referenced Specifications , but since it is in English, I will limit my explanation to the basics.
/bin
This directory contains commands for all users.
Creating subdirectories within this directory is prohibited.
There are 33 required commands, including ls, cat, ps, and mkdir, plus 9 optional commands.
All of these are certainly essential and basic commands.
The list is in 3.4. /bin: Essential user command binaries (for use by all users)
This includes more but not less,
so it's surprising that the less command isn't necessarily installed (the opinion of the less supporters).
/boot
This directory contains files related to the boot loader and inetd.
They are often placed in the master boot record of the HDD and are used before the OS starts.
/dev
This is where device files are stored.
The most useful files are those related to null and tty.
These files are used to access various devices.
/etc
etc. stands for "etcetera" (other).
In the very early days of Unix, it was a place to store files that could not be clearly classified as belonging to any particular group, but now it is used to store static configuration files, and executable binary files should not be placed there.
/home
This is a directory for storing each user's home directory.
How the home directory is used is up to the user, so it may simply be used to store personal files, or it may contain files for public access to the Internet, such as public_html, under the Apache user's home.
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 installed.
When I looked at /lib on my CentOS 7 computer, 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>
However, since the contents of /lib (/usr/lib) can often be used in both 32-bit and 64-bit environments, this directory itself is treated as optional.
Even when looking at Linux servers in operation, /lib64 can sometimes be sparse or even empty, making it difficult to use.
Please be careful as there is a case introduced in What to do when you can no longer mount a VirtualBox shared folder | Beyond Co., Ltd.
/media
Stores the mount point for removable media
However, there are several patterns for mount points for removable media, such as /cdrom directly under the root directory, /mnt itself being the mount point, or /mnt/cdrom, etc.
The FHS states that creating a mount point directly under the root directory is not recommended, as it means that a subdirectory will be created each time you mount it.
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
/opt is the installation directory for additional software and packages.
It can be /opt/[software package name], or you can place a directory with the software name between directories with the provider name registered with LANANA
Some people install software they have compiled themselves here.
This does not seem to be a problem from the FHS point of view, but there is a possibility that it may conflict with names registered in LANANA, so you should be careful to name it uniquely.
/root
This is the home directory of the root user.
If you place a file that other users may execute under this directory, you must be careful because the file will not be executed due to insufficient permissions.
/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 since booting,
including the pid file, lock file, and socket file.
/sbin
sbin stands for System Binaries and contains utility commands for system administrators.
These are commands provided by the distribution, and it seems that tools added by system administrators for management 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 the temporary directory that everyone loves.
When you reboot, /tmp is empty, and /var/tmp contains the information.
This is getting long so I'll continue in the second half
That's all
14