Linux directory-bird's Linux private cuisine

Source: Internet
Author: User
Tags time zones

Because there are so many communities/companies and individuals that use Linux to develop products or distributions, if everyone uses their own ideas to configure the directory where the files are placed, it can cause a lot of management problems. Can you imagine that after you entered a business, the Linux directory configuration method that you came into contact with was completely different from what you learned before? Hard to imagine ~ So, then there is the so-called Filesystem Hierarchy Standard (FHS) standards of the oven!

According to FHS's official paper, the main purpose is to allow users to understand that the installed software is usually placed in that directory, so they want independent software developers, operating system creators, and want to Users who want to maintain the system are able to follow the FHS standard. In other words, the focus of FHS is to standardize what data should be placed in each particular directory. This is a lot of benefit because the Linux operating system is able to develop the unique style that developers want under the existing landscape (directory architecture unchanged).

In fact, FHS is based on the past experience has been continuously revised, FHS based on the use of the file system and whether or not to allow users to change randomly, and the directory is defined as four interactive forms, in the form of a bit like the bottom:

The table above is a list of representative directories, the data placed under the directory will be discussed below, here first skip the talk. What we want to know is, what are those four types?

    • ?? Shareable: can be shared with other systems to mount the use of the directory, so including the execution of files and users of the mail and other data, is able to share to other hosts on the network mounted directory;

    • ?? Not to be shared: The device files that operate on their own machines, or socket files related to the program, are, of course, not suitable for sharing with other hosts because they are only relevant to their machines.

    • ?? Constant: Some of the data is not constantly changing, along with distribution without change. For example, a function library, file description file, the system administrator manages the host service configuration file and so on;

    • ?? Variable: frequently changing data, such as log-in files, newsgroups that are normally accepted by users, and so on.

      In fact, FHS only defines what data should be placed under the three-level directory for the directory tree schema, which is the definition of the three directories below:

Shareable (shareable)

Non-shareable (unshareable)

Immutable (static)/usr (software placement)

/etc (config file)

/OPT (third party collaboration software)

/boot (boot and core file)

Variable (variable)/var/mail (user email)

/var/run (program-related)

/var/spool/news (News Group)

/var/lock (program-related)

?? /(Root, root directory): related to boot system;

    • ?? /usr (Unix software Resource): Related to Software installation/execution;

    • ?? /var (variable): related to the system operation process.

      Why do you define these three-level catalogs? It's really meaningful. The directories under each level should be placed under specific rules. As we have not yet introduced the complete Linux system, so the following introduction you may not understand! It doesn't matter, there is a concept, until you read the basic article, you will have to read the basic article again! Then you will be enlightened! ^_^

      Tips:

      This root in Linux is really a lot of meaning, so much so that people do not understand what it is. In terms of "account", the so-called Root refers to "system administrator!" Identity, if the "directory" point of view, so-called root meaning is the root directory, that is/~ to pay special attention to Oh!

?? The meaning and content of the root directory (/):

The root directory is the most important directory for the entire system, because not only are all directories derived from the root directory, but the root directory is also associated with actions such as boot/restore/system repair. Because the system requires a specific boot software, core files, power on the required programs, function library and so on the file data, if the system error, the root directory must also include the ability to repair the file system of the program. Because the root directory is so important, so in terms of FHS requirements, he wants the root directory is not placed in a very large partition slot, because the larger the partition slot you will put more data, so that the root of the partition slot there may be more error opportunities.

Therefore FHS Standard recommendation: The root directory (/) where the partition should be smaller, the better, and the software installed by the application should not be placed in the same partition with the root directory, keep the root directory smaller the better. This is not only good performance, the root directory is located in the file system is less prone to problems.

Given the above explanation, FHS defines that the root directory (/) should have the following directories at the bottom:

Directory should place the contents of the archive

The system has a lot of directories for executing files, but/bin is more special. Because the/bin is placed in the single-mode maintenance mold/bin can also be operated instructions. The instructions under/bin can be used by root and general account, mainly

There are: Cat, chmod, chown, date, MV, mkdir, CP, bash, etc. commonly used directives.

This directory is mainly used to set up the boot will use the file, including the Linux core files and boot menu and boot/boot required configuration files and so on. Linux kernel commonly used file name: Vmlinuz, if you are using grub this

Boot management program, there will also be/boot/grub/this directory Oh!

On a Linux system, any device or interface device is present in this directory in the form of a file. You can access a device by accessing one of the files under this directory.

/dev/null,/dev/zero,/dev/tty,/dev/lp*,/dev/hd*,/dev/sd*, etc.

/etc

Most of the system's configuration files are placed in this directory, such as the person's account password file, the start of various services, and so on. In general, the file attributes in this directory are accessible to the general user, but only root has the power to modify it. FHS does not recommend 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/and so on. In addition, the following important directories are:

  • ?? /etc/init.d/: The preset startup script for all services is placed here, for example to start or close iptables: "/etc/init.d/iptables start", "/etc/init.d/iptables Stop"

  • ?? /etc/xinetd.d/: This is the configuration file directory for the various services called Super Daemon Management.

  • ?? /etc/x11/: Various configuration files related to x Window are here, especially xorg.conf this x Server configuration file.

/home

/lib

This is the system default user home directory (home directory). When you add a general user account, the default home directory will be standardized here. More importantly, the home directory has two codes: ~: Represents the current user's home directory, and
~dmtsai: It represents Dmtsai's home directory!

The system has a much more functional library, and/lib places a library of functions that will be used at boot time, as well as a function library that the instructions under/bin or/sbin will call. What is a function library? You can think of him as a "plug-in", some instructions must have these "plug-in" to be able to successfully complete the implementation of the program meaning. It is especially important to/lib/modules/this directory, because the directory will place the core related modules (drivers) Oh!

Media is the "medium" of English, as the name implies, this/media is placed under the removable device/media! Such devices as floppy disks, CDs, DVDs and so on are temporarily mounted here. The common file names are:

/media/floppy,/media/cdrom and so on.

If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory. In the early days of the/mnt, the use of this directory is the same as/media! Just after/media, this directory is used for temporary

The mount is used.

This is the directory for third-party software placement. What is third party collaboration software? For example, KDE

The desktop management system is a standalone program, but he can install it into a Linux system, so kde/opt's software is recommended to be placed in this directory. Also, if you want to install additional software on your own (not the original

Distribution), you can also install your software here. However, in the previous Linux system, we are still accustomed to place in the/usr/local directory!

The home directory of the system administrator (root). The reason for this is that if you go into single-player maintenance mode and only hang the/root root directory, that directory will be able to have the root home directory, so we would like Root home directory and root

     The directory is placed in the same split slot.

Linux has a lot of instructions to set up the system environment, these instructions only root can be used to "set up" system, the other users can only be used to "query" only. Placed under the/sbin for the boot process required, which includes the boot, repair, restore the system required instructions. As for some server software programs, it is generally placed in the/usr/sbin/. The system binaries generated by the natively installed software are placed in the/usr/local/sbin/. Common directives include: fdisk, fsck, Ifconfig, Init, MKFS, and so on.

SRV can be regarded as the abbreviation for "service", which is the/SRV data directory that these services need to take after some network services are started. Common services such as WWW, FTP and so on. For example, the Web page required by the WWW server

The data can be placed inside the/srv/www/.

This is where the general user or the executing program temporarily places the file. This directory is accessible to everyone in/tmp, so you need to clean it up regularly. Of course, important data can not be placed in this directory Ah! Because

FHS even suggest that you should remove the data from/TMP when booting up!

In fact FHS the standard defined for the root directory is just the top, but there are a lot of directories underneath our Linux that you need to know about. Below are a few of the most important directories in Linux:

/sbin

Directory

File contents should be placed

This directory is a directory that is generated using the standard EXT2/EXT3 file system format, in order to place some missing fragments into this directory when the file system has an error. This directory usually exists at the top level of the splitter slot, for example if you add a hard disk to/disk, and the system will automatically generate a directory like "/disk/lost+found"

/lost+found

The directory itself is a "virtual filesystem". The data he placed is in memory, such as the system core, the trip information (process), the state of the peripheral device, and the network status, and so on. Because the data in this directory is in the memory, so it does not occupy any hard disk space Ah! More important files such as:/proc/cpuinfo,/PROC/DMA,/proc/interrupts,/proc/ioports,/proc/net/* and so on.

/proc

/sys

This directory is in fact very similar to/proc, but also a virtual file system, mainly records and core

The relevant information. Including the core modules currently loaded and the core detected hardware device information, and so on. This directory also does not occupy the hard drive capacity Oh!

In addition to the contents of these directories, it is also important to note that because the root directory and boot-related, only the root directory will be mounted during the boot process, the other slots are the boot after the completion of the continuous loading behavior. Because of this, the root directory is related to the boot process of the directory, it can not be placed with the root directory in a different split slot! What directories are not separated from the root directory? There are these:

?? /etc: Configuration file
?? /bin: Important Execution file
?? /dev: Required device files
?? /lib: The function library required to execute the file and the module required by the core?? /sbin: Important System Execution files

These five directories must not be separated from the root directory in a different partition slot! Please carry it down! All right, we're done with the root directory, so let's talk about/usr and/var. first look at/usr for something:

?? 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 the partition slot through the network (for example, the NFS server that is discussed in the server), then/usr You can really share it with other hosts in the local area network.

Many readers will misunderstand/usr as user abbreviation, in fact, USR is the abbreviation of UNIX software Resource, that is, the "UNIX Operating system software resources" placed in the directory, rather than the user's data! This should be noted. FHS recommends that all software developers should place their data reasonably in the sub-directory under this directory, rather than building the software's own separate directory.

Because all system default software (software provided by distribution Publishers) is placed under/usr, this directory is somewhat similar to the "C:\Windows\ + C:\Program files\" combination of Windows systems, When the system has just been installed, this directory will occupy the most hard disk capacity. In general, the sub-directory of/USR suggests the following:

Directory should place the contents of the archive

/usr/x11r6/

The directory that was placed for the X Window System's important data is named X11R6 because the final x version is the 11th version, and the 6th release of the version is intended.

/usr/bin/

Most of the users can use the instructions here! Please note the difference between him and/bin. (whether it is related to the boot process)

/usr/include/c/c++ and other programming languages such as the header and the containing file (include), when we install some data in tarball way (*.tar.gz way), we will use a lot of included files inside!

A library of applications, a target file (object file), and a program that is not commonly used by

A line file or script. Some software will provide some special instructions for the server settings, these/usr/lib/instructions are not often operated by the system administrator, it will be placed in this directory. Note that if you are using a x86_64 Linux system, there may be/usr/lib64/directory generated

Oh!

The system administrator installs its own downloaded software (non-distribution default provider) on the machine, and recommends that the

Installed in this directory, which is easier to manage. For example, your distribution provides software that is older than/usr/local/, you want to install newer software but do not want to remove the old version, you can install the new version of the Software at

/usr/local/directory, and the original version of the software can be different! You can go to the/usr/local yourself to see, the directory is also has bin, etc, include, Lib ... The Secondary catalogue Oh!

/usr/sbin/

System directives that are required for non-system normal operation. The most common is the service instructions for some Web server Software (daemon)!

Where a shared file is placed, the data placed in this directory is almost always readable by the hardware architecture, because it is almost a text file! These secondary directories are common in this directory:

?? /usr/share/man: Online Help file
?? /usr/share/doc: Software Miscellaneous File description
?? /usr/share/zoneinfo: Time zone files related to time zones

/usr/share/

The general source code is suggested to be placed here, SRC has the meaning of source. The core source code is recommended to be placed in the/usr/src/linux/directory.

/usr/src/

?? The meaning and content of/var:

If/usr is a directory that occupies a larger hard disk capacity during installation,/var is the directory that will gradually take up the capacity of the hard disk after the system is operational. Because the/var directory is primarily for files with normal changes, including cache, login file (log file), and files generated by certain software operations, including program files (lock file, run file), or files such as MySQL database. Common sub-directories are:

The directory should place the archive content/var/cache/some temporary archives that will occur during the operation of the application itself;

The program itself executes the process that needs to be used to place the data file in the directory. In this directory the respective soft/var/lib/pieces should have their own directories. For example, MySQL's database is placed into/var/lib/mysql/and

RPM database is put in/var/lib/rpm!

Some devices or file resources can only be used by one application at a time, if there are two programs using the device, there may be some wrong situation, so it is necessary to lock the device (lock), to ensure that the device will only be used for a single software. For example, the recorder is burning a disc, do you think, there will be two people at the same time using a burner burning tablets? If two people are recording at the same time, whose data is written by that film? So when the first person is burning the burner is locked and the second person has to be unlocked (that is, the previous person ran out) to continue using it.

It's not important! This is the directory where the login files are placed! There are more important files such as/var/log/messages,/var/log/wtmp (log in information) and so on.

The directory where personal e-mail is placed, but this directory is also placed in the/var/spool/mail/directory! Usually the two directories are linked files for each other!

After some programs or services are started, their PID will be placed in this directory. As for the meaning of PID, we will refer to it in subsequent chapters.

      This directory usually places some queue data, the so-called "queue" is the number of queues waiting for other programs to use

That's it! This data is usually deleted after it is used. For example, the system receives a new letter that will be placed in/var/spool//var/spool/mail/, but the letter will be deleted in principle after the user has received the letter. If the letter is not sent out temporarily, it will be put into the/var/spool/mqueue/, and then deleted after being sent out. If it is

The work scheduling data (crontab) will be placed in the/var/spool/cron/directory!

It is recommended that after you have read the entire basic article, you can challenge FHS official English document (refer to this chapter reference data), I believe you will have a better understanding of the Linux operating system directory!

?? For FHS, the similarities and differences of each family distributions

Since FHS only defines the file or directory data that should be placed on the top (/) and sub-level (/usr,/var) directory content, it can be configured with the developer on its own at the other sub-directory levels. For example, the CentOS network setup data is placed in the/etc/sysconfig/network-scripts/directory, but SuSE is placing the network in the/etc/sysconfig/network/

/var/lock/

/var/log//var/mail//var/run/

Recorded, the directory name is different! But just remember the general FHS standard, the difference is actually limited!

Catalog tree (Directory trees)

In addition, under Linux, all the files and directories are started by the root directory! That's the source of all the directories and archives ~ and then one branch down, a bit like a twig ~ so we also call this directory configuration: "Directory tree" What are the characteristics of this directory tree? His main features are:

    • ?? The starting point of the directory tree is the root directory (/, root);

    • ?? Each directory can not only use the local-side partition file system, but also use the filesystem on the network. Example

      , you can use the Network File System (NFS) server to mount a specific directory, and so on.?? Each file name (including the full path) in this directory tree is unique.

Linux directory-bird's Linux private cuisine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.