In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what the directory structure of the linux system is, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
When using Linux, if you use ls-l /, you will find that there are many directories under /, such as etc, usr, var, bin. And so on, and in these directories, we go in and have a look, and find that there are also many directories or files. The file system looks like a tree structure under Linux, so we can vividly call the file system structure a tree structure.
File system is used to organize and arrange file access, so it is visible, in Linux, we can use tools such as ls to view its structure, in the Linux system, we see a tree structure; for example, the operating system is installed in a file system, it is shown as / starting tree structure. The top of the linux file system is /, which we call the root of Linux, that is, the file system of the Linux operating system. The entrance to Linux's file system is /, all directories, files, and devices are under /, / is the organizer and supreme leader of the Linux file system.
Because linux is open source, companies and groups do their own operations and programming according to the core code of linux. This makes a difference in the directory under the root. As a result, individuals cannot use the PC of other people's linux systems. Because you don't know some basic configuration and where the files are. This creates confusion. This is why the FHS (Filesystem Hierarchy Standard) institution was born. This organization is a group formed by linux enthusiasts spontaneously, mainly to make some basic requirements for linux, so that the operator will not become 'illiterate' if the host changes to another host.
According to FHS (http://www.pathname.com/fhs/) 's official document), their main goal is to let users know that installed software is usually placed in that directory, so they want independent software developers, operating system makers, and users who want to maintain the system to be able to follow FHS standards. In other words, the focus of FHS is to specify what kind of data should be placed in each particular directory. This has a lot of benefits, because the Linux operating system can develop the unique style that developers want under the existing look (the directory architecture remains the same).
In fact, FHS is constantly revised based on past experience. FHS defines directories as four forms of interaction based on how frequently the file system is used and whether users are allowed to change them at will, a bit like the following in terms of tables:
Shared (shareable)
Unshareable (unshareable)
Immutable (static)
/ usr (where the software is placed)
/ etc (profile)
/ opt (third party collaboration software)
/ boot (boot and core files)
Variable (variable)
/ var/mail (user mailbox)
/ var/run (program related)
/ var/spool/news (newsgroup)
/ var/lock (program related)
Types of the four middle schools:
1. Shareable:
Directories that can be shared with other systems for mounting, so data such as execution files and user mail are directories that can be shared with other hosts on the network.
two。 Not to be shared:
The device files running on your own machine or the socket files related to the program are, of course, not suitable for sharing with other hosts because they are only related to your own machine.
3. Immutable:
Some data do not change frequently, following the distribution and not changing. Such as function libraries, file description files, host service configuration files managed by system administrators, and so on.
4. Variable:
Frequently changed data, such as login files, newsgroups that ordinary users can receive on their own, and so on.
In fact, FHS only defines what data should be placed under the three-tier directory for the directory tree architecture, which are the definitions of the following three directories:
/ (root, root directory): related to boot system
/ usr (unix software resource): related to software installation / execution
/ var (variable): related to the operation of the system.
one。 The meaning and content of the root directory (/):
The root directory is the most important directory in the whole system, because not only all directories are derived from the root directory, but also related to boot / restore / system repair actions. Because the system needs specific boot software, core files, programs needed to boot, function libraries and other file data, if there is an error in the system, the root directory must also contain programs that can repair the file system. Because the root directory is so important, in terms of FHS's requirements, he hopes that the root directory will not be placed in a very large partition, because the larger the partition, the more data will be put in the partition, so there may be more opportunities for errors in the partition where the root directory is located.
Therefore, the FHS standard recommends that the partition of the root directory (/) should be as small as possible, and the software installed by the application should not be placed in the same partition as the root directory, and keep the root directory as small as possible. In this way, not only is the performance better, but also the file system where the root directory is located is less prone to problems. To put it bluntly, the root directory is the same as the C disk of Windows.
For the above reasons, FHS believes that the root directory (/) should contain the following subdirectories:
Catalogue
The contents of the file should be placed
/ bin
The system has many directories where execution files are placed, but / bin is special. Because / bin places instructions that can also be operated in single-person maintenance mode. The instructions under / bin can be used by root and general accounts, mainly: cat,chmod (modify permission), chown, date, mv, mkdir, cp, bash and other commonly used instructions.
/ boot
It mainly places the files used by the boot machine, including the Linux core files, the boot menu and the required configuration files, and so on. The common file name of Linux kernel is: vmlinuz, if you are using grub, the boot manager, the directory / boot/grub/ will also exist.
/ dev
On Linux systems, any devices and peripherals exist in this directory in the form of files. As long as you access a file in this directory, you are accessing a device. More important files are / dev/null, / dev/zero, / dev/tty, / dev/lp*, / dev/hd*, / dev/sd* and so on.
/ etc
Almost all the main configuration files of the system are placed in this directory, such as the account password file of personnel, the startup file of various services, and so on. Generally speaking, the properties of the files under this directory are accessible to the general user, but only root has the right to modify them. FHS recommends that you do not place 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/ and so on. In addition, the important directories under it are: / etc/init.d/: the default startup script for all services is placed here, for example, to start or disable iptables: / etc/init.d/iptables start, / etc/init.d/iptables stop
/ etc/xinetd.d/: this is the so-called profile directory of services managed by super daemon.
/ etc/X11/: all kinds of configuration files related to X Window are here, especially the two X Server profiles, xorg.conf or XF86Config.
/ home
This is the default user home directory (home directory) for the system. When you add a general user account, the default user home directory will be regulated here. More importantly, home catalogs have two code names:
~: represents the home directory of the current user, while ~ guest: represents the home directory with the user name guest.
/ lib
There are a lot of libraries in the system, and / lib places libraries that will be used when booting, and libraries that will be called by instructions under / bin or / sbin. What is a function library? You can think of it as a plug-in, and some instructions must have these plug-ins in order to successfully complete the execution of the program. Of particular importance is the / lib/modules/ directory, which places core-related modules (drivers).
/ media
Media is the English language of the media, and as the name implies, what is placed under this / media is a removable device. Including floppy disks, CD-ROMs, DVD and other devices are temporarily mounted here. Common file names are: / media/floppy, / media/cdrom, and so on.
/ mnt
If you want to mount some additional devices temporarily, it is generally recommended that you put them in this directory. In the early days, this directory was used for the same purpose as / media. It's just that with / media, this directory is used for temporary mount.
/ opt
This is a directory for third-party collaboration software. What is third-party collaboration software? For example, KDE, the desktop management system, is a stand-alone project, but it can be installed in Linux, so KDE's software is recommended to be placed in this directory. In addition, if you want to install additional software on your own (not provided by the original distribution), you can also install your software here. However, in previous Linux systems, we were used to placing it in the / usr/local directory.
/ root
Home directory of the system administrator (root). The reason for putting it here is that if you enter single maintenance mode and mount only the root directory, it will be able to have root's home directory, so we will want root's home directory to be placed in the same partition as the root directory.
/ sbin
Linux has a lot of instructions to set the system environment, these instructions can only be used by root to configure the system, other users can only be used to query. Put under / sbin is needed during the boot process, including the instructions 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 execution file (system binary) generated by the local self-installed software, it is placed in / usr/local/sbin/. Common instructions include: fdisk, fsck, ifconfig, init, mkfs and so on.
/ srv
Srv, which can be regarded as the abbreviation of service, is the data directory that some network services need to access after they are started. Common services such as WWW, FTP, etc. For example, the web data needed by the WWW server can be placed in / srv/www/. Hehe, it seems that the code we write should be put here.
/ tmp
This is the place for the general user or the running program to temporarily place the file. This directory is accessible to anyone, so you need to clean it up regularly. Of course, important materials cannot be placed in this directory. Because FHS even suggests that all data under / tmp should be deleted when booting.
In fact, the criteria defined by FHS for the root directory are limited to the above table, but there are still some directories that we need to know, as follows:
Catalogue
The contents of the file should be placed
/ lost+found
This directory is a directory that uses the standard ext2/ext3 file system format to place missing fragments in this directory when something goes wrong with the file system. This directory usually exists at the top of the partition slot. For example, if you add a hard disk to / disk, such a directory / disk/lost+found will be automatically generated under this system.
/ proc
The directory itself is a virtual file system (virtual filesystem). The data he places is in memory, such as the core of the system, process (is it a process?), the status of peripheral devices and network status, and so on. Because the data in this directory is in memory (memory), it does not take up any hard disk space. More important files (directories) such as / proc/cpuinfo, / proc/dma, / proc/interrupts, / proc/ioports, / proc/net/*, etc. Ha ha, is it virtual memory [guest]?
/ sys
This directory is actually very similar to / proc, which is also a virtual file system that records information related to the core. It includes the loaded core modules and the hardware device information detected by the core and so on. This directory also does not take up hard disk capacity.
In addition to the contents of these directories, it is also important to note that because the root directory is related to boot, only the root directory will be mounted during boot, and other partitions will be mounted continuously after the boot is completed. Because of this, directories related to the boot process in the root directory cannot be placed on a different partition from the root directory. Which directories cannot be separated from the root directory? Here are the following:
/ etc: configuration file
/ bin: important execution file
/ dev: required device file
/ lib: the function libraries required for the execution file and the modules required by the core
/ sbin: important system execution file
These five directories must not be separated from the root directory in a different partition. Please memorize it.
two。 The meaning and content of / usr:
According to the basic definition of FHS, the data placed in / usr is shareable and immutable (shareable, static). If you know how to mount partitioned data over the network (such as the NFS server discussed in the server section), then / usr can indeed be shared with other hosts in the LAN to use.
/ usr is not an acronym for user. In fact, usr is an abbreviation for Unix Software Resource, that is, the directory where Unix operating system software resources are placed, not the user's data. Pay attention to this. FHS suggests that all software developers should reasonably place their data in a subdirectory under this directory, instead of creating their own separate directories for the software.
Because all system default software (software provided by distribution publishers) is placed under / usr, this directory is a bit like the combination of C:\ Windows\ + C:\ Program files\ of Windows system. This directory takes up the most hard disk capacity when the system is installed. In general, the subdirectory of / usr recommends the following:
Catalogue
The contents of the file should be placed
/ usr/X11R6/
The directory placed for X Window System important data is named X11R6 because the last X version is version 11, and that version is released for the sixth time.
/ usr/bin/
Most of the instructions available to users are placed here. Please notice the difference between him and / bin. (whether it is related to the boot process)
/ usr/include/
When we install some data in tarball (*. Tar.gz) when we install some data, many of the included files are used when we install some data in the header and include of programming languages such as cUniverse +.
/ usr/lib/
Contains libraries of applications, object files (object file), and execution files or scripts that are not commonly used by ordinary users (script). Some software will provide some special instructions to set up the server, and these instructions will not be often operated by the system administrator, so they will be placed in this directory. It is important to note that if you are using the Linux system of X86room64, the / usr/lib64/ directory may be generated.
/ usr/local/
Unified administrators install their own downloaded software on this machine (not the default provider of distribution). It is recommended to install it to this directory, which will be easier to manage. For example, if the software provided by your distribution is old, and you want to install newer software but do not want to remove the old version, you can install the new version of the software in the / usr/local/ directory, which is different from the old one. You can go to / usr/local to see for yourself, this directory also has bin, etc, include, lib... Subdirectory of
/ usr/sbin/
System instructions that are not required for the normal operation of the system. The most common is the service instruction (daemon) of some network server software.
/ usr/share/
Where shared files are placed, the data placed in this directory is almost readable regardless of hardware architecture, because almost all of them are text files. Also common in this directory are these subdirectories: / usr/share/man: online help files
/ usr/share/doc: miscellaneous documentation for software
/ usr/share/zoneinfo: time zone file related to time zone
/ usr/src/
The general source code is recommended to be placed here. Src means source. As for the core source code, it is recommended to put it in the / usr/src/linux/ directory.
three。 The meaning and content of / var:
If / usr is a directory that takes up a large amount of hard disk capacity during installation, then / var is a directory that gradually takes up hard disk capacity after the system is running. Because the / var directory is mainly aimed at files with regular changes, including caches (cache), login files (log file), and files generated by some software operations, including program files (lock file, run file), or files such as MySQL database files. Common subdirectories are:
Catalogue
The contents of the file should be placed
/ var/cache/
Some temporary archives that will be generated during the operation of the application itself
/ var/lib/
During the execution of the program itself, you need to use the directory where the data files are placed. In this directory, each software should have its own directory. For example, MySQL's database is placed in / var/lib/mysql/ and rpm's database is placed in / var/lib/rpm
/ var/lock/
Some devices or file resources can only be used by one application at a time, and if two programs use the device at the same time, some error conditions may occur, so it is necessary to lock the device to ensure that the device is only used by a single software. For example, a burner is burning a CD. Do you think there will be two people using a burner to burn a disc at the same time? If two people burn it at the same time, whose data is written in that film? So when the first person is burning, the burner will be locked, and the second person will have to unlock the device (that is, the previous person has run out of it) before he can continue to use it.
/ var/log/
It's very important. This is the directory where the login file is placed. There are more important documents such as / var/log/messages, / var/log/wtmp (recording the login information) and so on.
/ var/mail/
The directory where the personal email box is placed, but this directory is also placed in the / var/spool/mail/ directory, usually the two directories are linked files to each other.
/ var/run/
When some programs or services start up, they place their PID in this directory
/ var/spool/
This directory usually places some queue data, and the so-called "queue" is the data queued for use by other programs. These data are usually deleted after they are used. For example, a new letter received by the system will be placed in / var/spool/mail/, but when the user receives the letter, the letter will in principle be deleted. Letters that cannot be mailed temporarily will be placed in / var/spool/mqueue/ and deleted after being sent. If it is work scheduling data (crontab), it will be placed in the / var/spool/cron/ directory.
Since FHS only defines the files or directory data that should be placed in the directory contents of the top layer (/) and secondary layer (/ usr, / var), it can be configured by the developer at other sub-directory levels.
four。 Directory tree (directory tree):
Under Linux, all files and directories start from the root directory. That is the source of all directories and files, and then branches down one by one. Therefore, we also call this directory configuration method: directory tree (directory tree). The main features of this directory tree are:
The starting point of the directory tree is the root directory (/, root)
Each directory can use not only the local partition file system, but also the filesystem on the network. For example, you can use a Network File System (NFS) server to mount a specific directory, and so on.
The file name (including the full path) of each file in this directory tree is unique.
If we display the entire directory tree graphically and list the more important file data, then the directory tree structure is shown in the following figure:
five。 Absolute path and relative path
In addition to the FHS directory configuration that requires special attention, we should also pay special attention to the file name section. Because according to the different way of writing the file name, the so-called path can also be defined as absolute path (absolute) and relative path (relative). These two file names / paths are written on the following basis:
Absolute path:
A file name or directory name written from the root directory (/), for example, / home/dmtsai/.bashrc
Relative path:
The file name relative to the current path. For example,. / home/dmtsai or http://www.cnblogs.com/home/dmtsai/ and so on. Anyway, it doesn't / belong to the relative path at the beginning.
And you have to understand that the relative path is expressed by the relative position of your current path. For example, if you are currently in the / home directory, how can you write if you want to enter the / var/log directory?
The code is as follows:
Cd / var/log (absolute)
Cd.. / var/log (relative)
Because you are under / home, you have to go back to the upper level (.. /) before you can continue to move to / var, pay special attention to these two special directories:
. Represents the current directory, or you can use. / to indicate
.. : represents the directory above, or.. / to represent.
This. With; with. The concept of catalog is very important. You will often see cd.. Or an instruction such as. / command represents the working status of the previous layer and the current directory.
Example 1: how to enter the / var/spool/mail/ directory and then enter the / var/spool/cron/ directory?
Command:
The code is as follows:
Cd / var/spool/mail
Cd.. / cron
Description:
Because / var/spool/mail and / var/spool/cron are also in the / var/spool/ directory. So you don't have to start from the root directory. This relative path is very helpful, especially for some software developers. In general, software developers place data in relative directories in / usr/local/. But what if the user wants to install to a different directory? You have to use a relative path.
Example 2: data like. / run.sh is often mentioned in network files. What is the meaning of this instruction?
Description:
As the execution of the instruction requires the support of variables, if your execution file is placed in this directory, and this directory is not a regular execution file directory (/ bin, / usr/bin, etc.), you must strictly specify the execution file if you want to execute the instruction. . / represents the meaning of this directory, so. / run.sh represents the execution of a file called run.sh under this directory.
These are all the contents of the article "what is the directory structure of the linux system?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.