The directory structure of Linux is created according to the standard called FHS (Filesystem Hierarchy Standard), and it seems that it has a history, so I investigated it myself. If you want to know more, please click here. →Filesystem Hierarchy Standard
The directories directly under the root directory specified by the current FHS (FHS 3.0) that are required are "/ bin", "/ boot", "/ dev", "/ etc", "/ lib", and "/ media". There are 14 "/ mnt", "/ opt", "/ run", "/ sbin", "/ srv", "/ tmp", "/ usr", and "/ var" ("/ home" and "/ root" are specified as options. ).
directory | role |
---|---|
/ | Root directory. This is the starting point of the hierarchy. |
/bin | Contains executable files needed to boot or repair the system in single-user mode. For example, executable files such as cat, cp, ls, more, tar. |
/boot | Includes Linux kernel, boot manager, etc. This directory contains only the files needed during the boot process. |
/dev | A device attached to a computer that references a physical device(Mouse, keyboard, disc, etc.)Where to put special files and device files. |
/etc | The directory that contains most system configuration files. Also in subdirectories/etc/rc.d contains the initialization script. |
/lib | The location where the shared libraries needed to boot the system and the shared libraries needed to execute commands on the root file system are located. |
/media | CD-Mount point for external media such as ROMs and floppy disks. |
/mnt | The mount point for the temporarily mounted file system. |
/opt | Places static files for add-on packages. |
/run | Contains data related to the running process. |
/sbin | /Like bin, this directory contains the commands needed to boot the system. However, commands that general users do not normally execute are placed here. |
/srv | Temporary files that can be deleted unconditionally are placed by regular jobs or at system startup. |
/tmp | Temporary files that can be deleted unconditionally are placed by regular jobs or at system startup. |
/usr | Contains files that the user installs independently. A structure similar to that directly under the route has been created. |
/var | Files that change in size, such as spool files and log files, are placed. |
When you actually hit the following command on Ubuntu, the following directory structure is displayed.
tree -d -L 2
Here, the directories (including options) directly under the root directory are explained in detail.
Contains commands that can be used by both system administrators and users. Required if no other file system is mounted (for example, single user mode). It may also contain commands that are used indirectly by the script.
Do not create subdirectories as the commands will not work.
The following commands are saved.
command | Description |
---|---|
cat | Utility to concatenate files to standard output |
chgrp | Utility to change ownership of filegroups |
chmod | Utility to change file permissions |
chown | Utility to change file owner and group |
cp | Utility to copy files and directories |
date | Utility to print or set system data and time |
dd | Utility to convert and copy files |
df | Utility to report file system disk space usage |
dmesg | Utility to print or control kernel message buffers |
echo | Utility to display lines of text |
false | false. Utility that does nothing |
hostname | Utility to display or set the host name of the system |
kill | Utility to signal a stop to a process |
ln | Utility to create links between files |
login | Utility to start a session on the system |
ls | Utility to list the contents of a directory |
mkdir | Utility to create a directory |
mknod | Utility to create special files for blocks or characters |
more | Utility for paging text |
mount | Utility to mount the file system |
mv | Move files/Rename utility |
ps | Utility to report process status |
pwd | Utility to output the name of the current working directory |
rm | Utility to delete files or directories |
rmdir | Utility to delete empty directories |
sed | "Sed" stream editor |
sh | POSIX compatible command shell |
stty | Utility to change and print terminal line settings |
su | Utility to change user ID |
sync | Utility to flush file system buffers |
true | true. Utility that does nothing |
umount | Utility to unmount the file system |
uname | Utility to print system information |
It has everything needed for the boot process, except for configuration files and map installers that aren't needed at boot time. It also contains data that is used before the kernel starts running user-mode programs, and may contain saved master boot sectors and sector map files.
The programs needed to allow the bootloader to boot files are located in / sbin. In addition, the boot loader configuration file that is unnecessary at startup is located in / etc.
No need to dig deep.
A system configuration file is a local file used to control the behavior of a program. It must be static and cannot be an executable binary. By the way, when you put the system configuration file in / etc, it is usually saved in a subdirectory instead of directly under it.
/ etc If the corresponding subsystem is installed, the following directory will be created and the configuration file will be saved in it. (Or there is a symbolic link to the directory.)
directory | Description |
---|---|
/etc/opt | System-wide initialization file for C-shell login |
/etc/X11 | NFS file system access control list |
/etc/sgml | Static information about the file system |
/etc/xml | Directory where XML configuration files are located |
Also, if the corresponding subsystem of / etc is installed, the following files are saved in / etc. (Or there is a symbolic link to the directory.)
File | Description |
---|---|
csh.login | System-wide initialization file for C-shell login |
exports | NFS file system access control list |
fstab | Static information about the file system |
ftpusers | FTP daemon user access control list |
gateways | A file listing the routed gateways |
gettydefs | Speed and device settings used by getty |
group | User group file |
host.conf | Resolver configuration file |
hosts | Static information about the host name |
hosts.allow | TCP wrapper host access file |
hosts.deny | TCP wrapper host access file |
hosts.equiv | List of trusted hosts for rlogin, rsh, rcp |
hosts.lpd | List of trusted hosts for lpd |
inetd.conf | inetd configuration file |
inittab | init configuration file |
issue | Pre-login message and identification file |
ld.so.conf | List of additional directories to search for shared libraries |
motd | Message after login of the file of the day |
mtab | Dynamic information about the file system |
mtools.conf | mtools configuration file |
networks | Static information about network names |
passwd | Password file |
printcap | lpd printer function database |
profile | system-wide initialization file for sh shell login |
protocols | IP protocol list |
resolv.conf | Resolver configuration file |
rpc | RPC protocol list |
securetty | TTY access control for root login |
services | Network service port name |
shells | Valid login shell pathname |
syslog.conf | syslogd configuration file |
No need to dig deep.
Contains the shared libraries needed to boot the system and execute commands on the root file system. The following files are placed.
File | Description |
---|---|
libc.so.* | Dynamically linked C library |
ld* | Runtime linker/Loader |
/ lib If the corresponding subsystem is installed, the following directory will be created and the module will be saved in it. (Or there is a symbolic link to the directory.)
directory | Description |
---|---|
modules | Loadable kernel module |
Contains subdirectories used as mount points for removable media such as floppy disks, CD-ROMs, and zip disks.
/ media If the corresponding subsystem is installed, the following directory will be created and the module will be saved in it. (Or there is a symbolic link to the directory.)
directory | Description |
---|---|
floppy | Floppy drive |
cdrom | CD-ROM drive |
cdrecorder | CD writer |
zip | Zip drive |
iso | iso drive |
No need to dig deep.
Directory reserved for installing add-on application software packages. The directory structure is / opt / bin, / opt / docm, / opt / include, / opt / info, / opt / lib, and / opt / man.
Programs that users call must be placed under the directory / opt /
Install variable (normal operation changes) package files in / var / opt.
No need to dig deep.
No need to dig deep.
Contains system information data that describes the system after booting. Files under this directory are cleared (deleted or truncated as needed) at the start of the startup process.
In addition to the binaries used for system administration, there are binaries that are essential for system boot, restore, recovery, and / or repair.
Do not create subdirectories as the commands will not work.
The following commands are saved.
command | Description |
---|---|
fastboot | Reboot the system without checking the disk |
fasthalt | Shut down the system without checking the disk |
fdisk | Partition table manipulator |
fsck | File system check and repair utility |
fsck.* | File system check and repair utility for a particular file system |
getty | Getty Program |
halt | Command to stop the system |
ifconfig | Network interface configuration |
init | Initial process |
mkfs | Command to build a file system |
mkfs.* | Commands to build a specific file system |
mkswap | Command to set swap area |
reboot | Command to restart the system |
route | IP Routing Table Utility |
swapon | Enable paging and swapping |
swapoff | Disable paging and swapping |
update | A daemon that periodically flushes filesystem buffers |
A directory containing data for services such as HTTP and FTP.
No need to dig deep.
A directory provided for use by programs that require temporary files.
Many programs, such as the X Window System, are stored in subdirectories.
Host-specific information and information that changes over time is stored elsewhere (the former under / etc, the latter under / var).
There are the following directories.
directory | Description |
---|---|
/usr | Many programs, such as the X Window System, are stored in subdirectories. |
/usr/bin | It contains many non-core Linux operating system executables. |
/usr/include | C or C++I put a header file such as. |
/usr/lib | /usr/bin/Or/usr/sbin/The base library for executable files in(library)group(C or C++Library files such as)Is placed. |
/usr/sbin | Non-basic system executable files(Administrative commands)Is placed. For example, daemons for various network services. |
/usr/share | It has shared files such as default configuration files, images, and documents. |
/usr/src | The source code of the Linux kernel is placed. For example, the kernel source code and its header files. |
/usr/X11R6 | X Window System,There is a Version 11 Release 6 application. |
/usr/local | /It is similar to the usr directory and has local files. |
There are the following directories.
directory | Description |
---|---|
/var | Contains various system files such as logs, mail, and print spools. |
/var/cache | It stores the cached data of the application. |
/var/lib | Contains information about the status of the application. |
/var/lock | There is a lock file to check for double startup. |
/var/log | I have a log file. |
/var/mail | Contains the user's email data. |
/var/opt | /The data of the package in the optdh directory is stored. |
/var/run | The system data after booting is stored. |
/var/spool | The data waiting for the process is stored. |
/var/tmp | I have a temporary file for system reboot. |
-Linux bean knowledge 173-FHS (Filesystem Hierarchy Standard)
Recommended Posts