There is a rule called FHS that summarizes the layout of Linux system directories - Part 1 -
Hello.
I'm Mandai, in charge of Wild on the development team.
When you first start using Linux, you may feel like you have a vague idea of where the apache config is.
There are good reasons for the structure of the Linux system directory, the names and locations of each directory, and I thought that if you knew that, you would be able to understand things more easily, so I would like to send you an article that summarizes FHS. .
What is FHS?
FHS stands for "File Hierarchy Standard", which defines the standard for Linux file structure.
Knowing this and entering the Linux console will help you understand why a file is there and 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 generally have the same structure.
There are also versions of FHS, and 3.0 is currently being developed.
This release date is May 18, 2015, so it seems that the content will change with the times.
Configuration below the root directory
The original text of the latest FHS3.0 the FHS Referenced Specifications , but since it is in English, I will focus on the basic parts.
/bin
Command storage location for all users.
Creating subdirectories within this directory is prohibited.
There are 33 required commands and 9 optional commands such as ls, cat, ps, and mkdir.
All of them are basic commands that are certainly required.
The list can be found in 3.4. /bin : Essential user command binaries (for use by all users)
This includes "more" and "less".
Therefore, it is surprising that the less command is not necessarily installed (opinion of the less group).
/boot
This directory contains files related to the bootloader and inetd.
It is often placed in the master boot record of the HDD and seems to be used before starting the OS.
/dev
This is where device files will be stored.
It contains files related to null and tty, which are likely to be the most useful.
This file is used to access various devices.
/etc
etcetera (other) meaning etc.
In the very early days of Unix, it seems that this was a place to store files that could not be clearly classified to which one, but now it is a place for static configuration files, and executable binary files cannot be placed there. I am.
/home
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 a place for personal files, or it may be a place under the apache user's home directory, such as public_html, to store files for public viewing on the Internet. .
Note that the installation of /home is treated as an option, so it seems that there should be no problem with the system even without it.
/lib
This is the location for shared libraries and kernel modules.
When I looked at /lib on my CentOS7, this directory itself was a symbolic link to /usr/lib.
In this way, in Linux, thanks to symbolic links, it is possible to follow FHS version upgrades without affecting existing systems.
/lib<qual>
The part contains the number of bits of the system.
/lib64 stores shared libraries specific to 64-bit environments.
However, since things in /lib (/usr/lib) can often be used for both 32-bit and 64-bit, this directory itself is treated as an option.
Even if you look at a Linux server that is actually in operation, /lib64 is sometimes empty or empty, so it is difficult to use it.
What to do when the VirtualBox shared folder cannot be mounted | There is also a case introduced in Beyond Co., Ltd., so be careful.
/media
Stores mount points for removable media.
However, there are several mount points for removable media, such as /cdrom directly under the root directory, /mnt itself, or /mnt/cdrom.
FHS says that creating a mount point directly under the root directory is not a good idea because a subdirectory will be created each time it is mounted.
Also, it seems that it has recently become common to use /mnt as a mount point, but in very old systems, /mnt itself may be used as a temporary mount point, so there is a possibility of configuration conflicts. Since there is, it is better to use /media.
/mnt
In the past, /mnt was very commonly used as a mount point, but in FHS3.0, it is now used in a rather limited and passive manner as a temporary file system for system administrators. I am giving advice to keep it in place.
/mnt is treated as temporary, so the file system mounted here should not affect the operation of any programs being executed.
/opt
/opt is provided as a destination for installing additional software and packages.
/opt/[software package name] or set up a directory with the software name between the directories with the provider name registered in LANANA
Some people install their own compiled software here.
Although this itself does not seem to be a particular problem in terms of FHS, there is a possibility that it will conflict with the name registered in LANANA, so you should be careful when naming it to ensure it is unique.
/root
This is the root user's home directory.
If you place a file under this that may be executed by other users, you will not be able to execute it due to insufficient privileges, so be careful.
/root doesn't seem to be a required directory either, but if it's not there, "/" seems to be considered the root home directory, which can be confusing, so it's probably better to set it up.
/run
This directory stores system information since boot.
It mainly contains pid files, lock files, socket files, etc.
/sbin
sbin stands for System binaries, which contains utility commands for system administrators.
The commands here are prepared by the distribution, and it seems that any tools added by the system administrator for management should be added under /usr/sbin.
/srv
This is set up to make it easier to find and manage data files for services running on the server in an integrated manner.
However, there is no particular decision on how to create a file structure using /srv, so it is empty in CentOS7.
One method is to create a directory based on the protocol, place a directory with the name of the service that uses that protocol in the subdirectory, and layout it to place configuration files, management scripts, etc.
/tmp
This is everyone's favorite temporary directory.
When you restart, /tmp will be empty and /var/tmp will be empty.
This is getting too long so I'll continue in the second half.
That's it.