In Linux, the root directory "/" is located at the top level of the file system directory structure and is the top-level directory. All files and directories are placed under the root directory "/"; the root directory "/" "There are also subdirectories such as "/bin", "/home", and "/usr" below.
#The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.
The file system of Linux and UNIX is a hierarchical tree file structure with "/" as the root, "/" is therefore called Root directory.
All files and directories are placed under the root directory "/". There are subdirectories such as /bin, /home, /usr and so on under the root directory /.
FHS standard recommendation: The partition where the root directory "/" is located should be The smaller the better, and the software installed by the application should not be placed with the root directory Within the same partition, keep the root directory as small as possible.
Linux philosophy
1. Everything is a file;
2. Small programs with a single purpose; combine small programs to complete complex tasks;
3. Try to avoid capturing the user interface;
4. Save the configuration information of the program through the configuration file, and the configuration file is usually a plain text file;
$ ls / bin dev home lib64 mnt proc run srv usr boot etc lib media opt root sbin sys tmp var
(1)bin
Binary binary
The storage directory of the executable program files corresponding to many "instructions" ls
, pwd
, init
etc.
(2)boot
Mainly places files used for booting, including Linux core files, boot menu and configuration files required for booting, etc. wait. The commonly used file name of Linux kernel is: vmlinuz . If you are using grub, the boot management program, the directory /boot/grub/ will also exist!
(3) dev
On a Linux system, any device and peripheral equipment exists in this directory in the form of files. Simply accessing a file in this directory is equivalent to accessing a device. The more important files include /dev/null, /dev/zero, /dev/tty, /dev/lp*, /dev/hd*, /dev/sd*, etc.
(4) etc
Almost all the main configuration files of the system are placed in this directory, such as personnel account and password files, startup files of various services, etc. Generally speaking, the attributes of each file in this directory can be viewed by ordinary users, but only root has the authority to modify them. FHS recommends not placing executable files (binary) in this directory. The more important files are: /etc/inittab, /etc/init.d/, /etc/modprobe.conf, /etc/X11/, /etc/fstab, /etc/sysconfig/, etc. In addition, the important directories under it are:
(5) home
This is the system’s default user home directory. When you add a general user account, the default user home directory will be standardized here. More importantly, the home directory has two codenames:
~: represents the current user's home directory, and ~guest: represents the home directory of the user named guest!
(6)lib
There are many function libraries in the system, and /lib places the function libraries that will be used when booting, as well as in /bin or /sbin The following command will just call the function library. What is a function library? You can think of it as a "plug-in". Certain instructions require these "plug-ins" to successfully complete the execution of the program. Particularly important is the directory /lib/modules/, because this directory will contain core-related modules (drivers)!
(7) lib64
(8) media
Media is the English word for "media". As the name suggests, the removable device placed under /media is! Devices including floppy disks, compact discs, DVDs, etc. are temporarily mounted here. Common file names include: /media/floppy, /media/cdrom, etc.
(9)mnt
If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory. In ancient times, the purpose of this directory was the same as /media! Only after /media is created, this directory is used for temporary mounting.
(10)opt
This is the directory where third-party collaborative software is placed. What is third-party collaborative software? For example, the KDE desktop management system is an independent project, but it can be installed on a Linux system, so it is recommended that KDE software be placed in this directory. In addition, if you want to install additional software (not provided by the original distribution), you can also install your software here. However, in previous Linux systems, we were still used to placing it in the /usr/local directory!
(11)proc
This directory itself is a "virtual filesystem (virtual filesystem)"! The data he places are all in the memory, such as the system core, process information (is it a process?), the status of peripheral devices, network status, etc. Because the data in this directory are all in the memory (memory), it does not occupy any hard disk space! More important files (directories) such as: /proc/cpuinfo, /proc/dma, /proc/interrupts, /proc/ioports, /proc/net/*, etc. Haha, is it virtual memory [guest]?
(12) root
The home directory of the system administrator (root). The reason why it is placed here is because if you enter single-player maintenance mode and only mount the root directory, the directory can have root's home directory, so we would like root's home directory and the root directory to be placed in the same partition.
(13)run
The things inside are needed when the system is running and cannot be deleted casually. But they should be discarded when restarting. They will be regenerated the next time the system is running.
(14)sbin
Linux has a lot of commands used to set the system environment. These commands can only be used by root to "set" the system, othersUsers can only use it to "query" at most. What is placed under /sbin is what is needed during the boot process, including the commands needed to boot, repair, and restore the system. As for some server software programs, they are generally placed in /usr/sbin/. As for the system executable file (system binary) generated by the software installed on the local machine, it is placed in /usr/local/sbin/. Common instructions include: fdisk, fsck, ifconfig, init, mkfs, etc.
(15)srv
srv can be regarded as the abbreviation of "service". It is the data directory that these services need to access after some network services are started. Common services such as WWW, FTP, etc. For example, the web page data required by the WWW server can be placed in /srv/www/. Haha, it seems that the code we usually write should be placed here.
(16) sys
This directory is actually very similar to /proc. It is also a virtual file system that mainly records core-related information. Including currently loaded core modules and hardware device information detected by the core, etc. This directory also does not occupy hard disk space!
(17)tmp
This is a place where ordinary users or running programs can temporarily place files. This directory is accessible to anyone, so you need to clean it regularly. Of course, important information cannot be placed in this directory! Because FHS even recommends that all data under /tmp should be deleted when booting!
(18) usr
/usr is the core of the system and contains all shared files. It is one of the most important directories in the unix system, covering binary files, various documents, various header files, x, and various library files; there are also many programs, such as ftp, telnet, etc.
(19)var
/var/log, log file
/var/run, pid file
/var/mail, the storage location of user mail
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What is the root directory in linux. For more information, please follow other related articles on the PHP Chinese website!