Linux directory Structure configuration

Source: Internet
Author: User

Because there are so many developers of Linux, if everyone develops their own directory configuration method, it can cause a lot of management problems. So, there is a standard called Filesystem Hierarchy Standards (FHS) came out.

The FHS (http://www.pathname.com/fhs/) is actually just a specification of what kind of files should be placed under the root directory (/) for each major directory. FHS defines the two-layer specification, the first layer is/under the various directories should be placed on what content of the file data, such as/etc should be placed configuration files,/bin and/sbin should be placed executable files and so on. The second tier is defined for the sub-directories of the/USR and/var directories. For example,/var/log places system registry files,/usr/share places shared data, and so on.
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:

TR align= "center" bgcolor= "#182448" > /tr>
shareable (shareable) non-shareable (unshareable)
invariant (static) /usr (software placement) /etc (config file)
/opt (third party software) /boot (boot and core)
variable (variable) /var/mail (user mail mailbox) /var/run (program-related)
/var/spool/news (newsgroup) /va R/lock (Program-related)
    • 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 file or socket file related to the program is not suitable for sharing with other hosts because it is only related to its own machine.
    • 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.

We can take a look at the directory configuration structure under the "/" root directory by ls-l/this command:

[Email protected]:/# ll/ Total thedrwxr-xr-x -Root root4096September8  One: -./drwxr-xr-x -Root root4096September8  One: -.. /drwxr-xr-x2Root root4096May -  -: -bin/drwxr-xr-x3Root root4096September8  One: theboot/DRWXRWXR-X2Root root4096October -   .cdrom/drwxr-xr-x -Root root3960September8  -: +dev/drwxr-xr-x131Root root12288September8  -: -etc/drwxr-xr-x5Root root4096September8  -: thehome/lrwxrwxrwx1Root root -September8  One: -Initrd.img-boot/initrd.img-4.4.0-134-genericlrwxrwxrwx1Root root -July9  -: theInitrd.img.old-boot/initrd.img-4.4.0- the-GENERICDRWXR-xr-x ARoot root4096June One  the: -lib/drwxr-xr-x2Root root4096June One  the: -lib32/drwxr-xr-x2Root root4096May -  -: -lib64/drwx------2Root root16384October -   .lost+found/-rw-r--r--1Root root0December7   .MAIN.CDRWXR-xr-x3Root root4096October -   .media/drwxr-xr-x2Root root4096July -   .mnt/drwxr-xr-x2Root root4096July -   .opt/Dr-xr-xr-x182Root root0September8  -: +proc/drwx------ -Hwli Root4096September8  -: Aroot/drwxr-xr-x -Root root740September8  -: -run/drwxr-xr-x2Root root12288September8  One: -sbin/drwxr-xr-x2Root root4096June -   .snap/drwxr-xr-x2Root root4096July -   .srv/Dr-xr-xr-x -Root root0September8  -: +sys/DRWXRWXRWT8Root root4096September8  -: -tmp/drwxr-xr-x ARoot root4096June One  the: -usr/drwxr-xr-x -Root root4096July -   . var/lrwxrwxrwx1Root root -September8  One: -Vmlinuz-boot/vmlinuz-4.4.0-134-genericlrwxrwxrwx1Root root -July9  -: theVmlinuz.old-boot/vmlinuz-4.4.0- the-Generic[email protected]:/#

Are we already familiar with the attributes of the previous ones?

If you want to look at a more complete tree directory, the entire Linux system tree can be used to represent:

We can see that all of these directories are attached to the "/" root directory, which is what we commonly called "tree-like directory." According to the FHS definition, the file contents that should be placed within each directory should be as follows:

The main configuration files of the
Directory File contents should be placed
FHS the list of provisions
/bin The system has a lot of directories for executing files, but/bin is more special. Because the /bin is placed in the single maintenance mode can also be operated instructions. The commands under/bin can be used by root and general account, mainly: Cat, chmod, chown, date, MV, mkdir, CP, Bash and so on.
/boot This directory is mainly used to put the files on the boot, including the Linux core files and boot menu and boot required configuration files and so on. Linux kernel commonly used file name: Vmlinuz, if you are using grub this boot manager, there will be/boot/grub/this directory!
/dev On a Linux system, any device or interface device is present in this directory in the form of a file. All you have to do is access one of the files under this directory to access a device that is more important than /dev/null,/dev/zero,/dev/tty,/dev/lp*,/dev/hd*,/dev/sd*, etc.
/etc system are placed almost 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 it is recommended that you do not place executable files (binary) in this directory. The more important documents 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/: Preset startup script for all services is put 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 of the various services that are called Super Daemon Management.
  • /etc/x11/: The various configuration files related to x Window are here, especially xorg.conf this x Server configuration file.
/home 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 types of code: ~: Represents the current user's home directory, and ~vbird: it represents vbird home directory!
/lib 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)!
/media Media is the "medium" of English, as the name implies, this /media is placed under the removable device! Such devices as floppy disks, CDs, DVDs and so on are temporarily mounted here. Common file names are:/media/floppy,/media/cdrom, and so on. (Our disc image files are usually mounted in the media directory)
/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 use of this directory is the same as/media! Just after the/media, this directory is used for temporary loading.
/opt This is the directory for third-party software placement. What is third party collaboration software? For example, the KDE desktop Management system is a standalone program, but it can be installed on a Linux system, so KDE software is recommended to be placed in this directory. Also, if you want to install additional software on your own (not provided by the original distribution), you will be able to install your software here as well. However, in the previous Linux system, we are still accustomed to place in the/usr/local directory!
/root The home directory of the system administrator (root). The reason for this is that if you go into single-player maintenance mode and only mount the root directory, that directory will be able to have the root home directory, so we would like Root home directory and root directory in the same partition slot.
/sbin 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 SRV can be considered an abbreviation for "service", which is the data directory to be used by some network services after they are started. Common services such as WWW, FTP and so on. For example, the Web page data required by the WWW server can be placed inside the/srv/www/.
/tmp This is where the general user or the executing program temporarily places the file. This directory is accessible to anyone, so you need to clean it up regularly. Of course, important data can not be placed in this directory Ah! Because FHS even suggested that the data at/TMP should be removed when booting
List of non-FHS provisions
/lost+found 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"
/proc This directory itself is a "virtual file system (FileSystem)" Oh! The data he places are in memory, such as the system core, the trip information (process), the state of the peripheral device, and the network status. Because the data in this directory is in memory, so it does not occupy any hard disk space! More important documents such as:/proc/cpuinfo,/PROC/DMA,/proc/interrupts,/proc/ioports,/proc/net/* and so on.
/sys This directory is very similar to/proc, but also a virtual file system, which is also the key to record the information related to the core. Including the core modules currently loaded and the core detected hardware device information, and so on. This directory also does not account for hard disk capacity
Usr The second level of content by the FHS specification, in/usr This directory, contains the system's main program, graphics interface required files, additional library, the local side of the software installed by itself, as well as shared directories and files, etc., can be found in this directory. In fact, he is a bit like the "Program Files" and "WinNT" in the Windows operating system to combine the two directories! The important sub-directories under this directory are:
  • /usr/bin,/usr/sbin: directory where the general identity user and the system administrator can perform file placement;
  • /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! ;
  • /usr/lib: The library files directory of each application software;
  • /usr/local: The default directory where the native-side software installs itself. It is also available for the/OPT directory. After you have installed Linux, basically all the equipment you have, but the software can always be upgraded, for example, you want to upgrade your proxy service, the software is usually the default installation is in the/usr/local (Local is "locally" meaning), at the same time, After the installation of the resulting execution files, in order to be different from the original execution of the system, so the upgraded execution file is usually placed in the/usr/local/bin this place.
  • /usr/share: A directory for shared file placement, such as the bottom two directories:
  • /usr/share/doc: Place some system documentation, for example, if you have grub installed, then look it up under that directory and you can find the GRUB documentation! It is very convenient!
  • /usr/share/man:manpage file directory, when using man, will go to query the path! For example, when you use the man ls command, you will find the contents of/usr/share/man/man1/ls.1.gz this document!
  • /usr/src:linux system-related program code placement directory, such as/usr/src/linux as the core of the original code!
  • /USR/X11R6: Almost all of the execution files required for the X Window system within the systems are placed here!
 /var   This directory is also important and is the second-level directory content of the FHS specification. His main place is for the system execution process, the normal changes in the file placement directory. For example, a cached file (cache), or a log file that is changed at any time, is placed in this directory. In addition, some of the database files that are written during the execution of the software, such as the MySQL database, are also written in this directory! The following important directories are:
  • /var/cache: Some temporary disks in the process of the program files;
  • /var/lib: The program itself executes the process, need to use the data files placed in the directory, for example, locate this database and MySQL and RPM database system, are written in this directory.
  • /var/log: directory where the login file is placed. It's important! For example/var/log/messages is a file of all login files!
  • /var/lock: Some appliances have a one-time write feature, such as tab (Tape drive), at which point, in order to worry about being disturbed by others to disrupt the operation of the action, therefore, The device will be lock (locked) to make sure that the device can only be used by a single program!
  • /var/run: When some programs or services are started, their PID will be placed in this directory!
  • /var/spool: is where some queue data is stored. For example, when the host receives the e-mail, it will be placed in the/var/spool/mail, if the letter is temporarily not sent out, it will be placed in the/var/spool/mqueue directory, the user task Assignment (cron) is placed in the/var/spool/cron Of

Several categories of particular importance

    • /etc: This directory is where the system configuration files are placed, including the account number and password (/etc/passwd,/etc/shadow) on your system, as well as the set values (/etc/sysconfig/*) to be used when booting, as well as the configuration files of each major network service. are in this directory. This means that if the files under this directory are deleted or are dead, we will have to spend a lot of time restoring the files in this directory. Therefore, it is generally recommended that this directory be backed up!
    • /usr/local: Although the importance of this directory has now been moved to/OPT, I am still more accustomed to placing myself in this/usr/local directory with software that I have developed myself or installed on my own. If your Linux system is a multi-person condominium, it is necessary to develop a good operating habit. Then the habit of installing software should be well built up AH ~ do not install it at random! Put it in the/usr/local or under the/opt!
    • /var: This directory is an important intermediate staging data during the operation of the management system, such as/var/lib and/var/run. In addition, the final data such as Mail/var/spool/mail is also placed in this directory in addition, almost all the services of the login file (can record who, when, where to log in the machine, what to do and so on information! are placed in the/var/log directory, so this directory is also important.

This essay is mainly recorded in-depth study of Linux file attributes and directory structure of some experience, if there are errors, but also hope that we can point out!!

Resources:

Https://www.cnblogs.com/xiaoluo501395377/archive/2013/04/20/3033131.html

Linux directory structure configuration

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.