Linux directory structure detailed

Source: Internet
Author: User
Tags time zones system log

due to the use There are so many teams and individuals in Linux to develop the product, imagine that if everyone is using their own ideas to configure the directory of file placement, then management will be very disturbing. In order to control the configuration of the Linux file directory is extremely chaotic situation, the Linux directory configuration standard FHS (Filesystem Hierarchy standards) is out of the way, FHS focus on the specification of each particular directory should be put what kind of data. This greatly facilitates independent software developers, operating system creators and system maintenance personnel.

FHS defines what data should be placed under the three-tier directory for the directory tree schema, and the three-tier directory is:

1,/(root, root directory): Related to the boot system;

2./usr (UNIX software Resource): Related to Software Installation/execution

3,/var (variable): related to the system operation process

1. The meaning and content of the root directory (/)

  The root directory is related to operations such as power-on, restore, and system repair. FHS Standard Recommendation: The root directory (/) should be the smaller the partition should be the better, and the software installed by the application should not be placed in the same partition as the root directory, keep the root directory as small as possible, so not only good performance, the root directory of the file system is less prone to problems.

  FHS define the root directory (/) below should be the existence of these subdirectories:

Directory

File contents should be placed

/bin

The system has a lot of directories for executing files, but/bin is more special. Because/bin places commands that can be manipulated in single-user maintenance mode. In/bin the following commands can be used by root and general account, mainly with Cat,chmod,chown,date,mv,mkdir, Cp,bash and other commonly used commands.

/boot

This directory mainly places the files that will be used to boot, including the Linux kernel files and the boot menu and the required configuration files. LINUX kernel commonly used file name is Vmlinuz, if you use grub this boot loader, there will also be/boot/grub/this directory

/dev

On Linux systems, any device and interface device exists in this directory in the form of files. You simply access a device by accessing one of the files under this directory. More important documents are/dev/null,/dev/zero,/dev/tty,/dev/lp*,/dev/hd*,/dev/sd*, etc.

/etc

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

A./etc/init.d/: The default startup scripts for all services are placed here, for example to start or close iptables: "/etc/init.d/iptables start", "/etc/init.d/iptables Stop"

B./etc/xinetd.d/: This is the configuration file directory of the various services called Super Daemon Management

C./etc/x11/: Various configuration files related to X window are here, especially xorg.conf this xserver configuration file

/home

This is the default User home folder (home directory), when you create a general user account, the default User home folder will be standardized here. More importantly, the home folder has two types of code:

~: Represents the home folder of the currently logged-on user

~dmtsai: Represents Dmtsai's home folder

/lib

There are a lot of libraries in the system, and/lib places the library of functions that will be used at boot time, as well as the function libraries that the commands under/bin or/sbin call. What is a function library? You can think of it as a "plug-in", some commands must have these "plug-in" to be able to successfully complete the implementation of the program meaning. It is particularly important to/lib/modules/this directory because it will place kernel-related modules (drivers)

/media

The/media place is a removable device. devices, including floppy disks, CDs, DVDs, and so on, are temporarily mounted here. Common filenames are/media/floppy,/media/cdrom, etc.

/mnt

If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory. In earlier times, this directory was used in the same way as/media. Only after the/media, this directory is used to temporarily mount the

/opt

Directories placed by third-party software

/root

The home folder of the system administrator (root). The reason for this is that if you go into single-user maintenance mode and only mount the root directory, that directory will be able to have the root home folder, so we would like Root's home folder and root directory to be placed in the same partition

/sbin

Linux has a lot of commands to set up the system environment, these commands only root can use to "set up" the system, 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 commands. As for some server software programs, it is generally placed in the/usr/sbin/. The system execution file (Systen binary) generated by the natively installed software is placed in the/usr/local/sbin/. Common commands include Fdisk, fsck, ifconfig, INIT,MKFS, etc.

/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, for example, the Web page data required by the WWW service can be placed in/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 cannot be placed in this directory. Because FHS even recommends that you remove the data from/TMP when booting

In addition, an important directory such as /lost+found,/proc,/sys is not within the standard defined by FHS, and the/lost+found directory is a directory that is generated using the standard EXT2/EXT3 file system format. The purpose is to put some missing fragments into this directory when the file system error occurs,/proc,/sys belong to the virtual file system, the data is stored in memory and does not occupy disk space.

Note: In the boot process, as long as the root directory will be mounted, the other partitions will continue to mount after the boot is completed, so in the root directory associated with the boot directory (including /etc,/bin,/dev,/lib,/sbin) can not be placed in a different partition with the root directory, Otherwise, you will encounter strange error.

2. the meaning and content of/usr

based on The basic definition of FHS, the data placed in/USR is shareable and immutable, USR is the abbreviation for UNIX software resource, which is the directory placed by the UNIX operating system software resource, not the user's data. All system default software (software provided by distribution Publishers) is placed under/usr. This directory consumes the most disk capacity when the system has just been installed.

Directory

File contents should be placed

/usr/x11r6

For the X Window System important data placed in the directory, the reason is named X11R6 because the last X version of the 11th version, and this version of the 6th release of the meaning

/usr/bin/

Most of the users can use the command to put it here. Notice the difference between it and the/bin (whether it is related to the boot process)

/usr/include

The header file and the include file (include) in the program language such as C + +, when we install some data in the Tarball Way (*.tar.gz), we use many of the included files inside

/usr/lib

A library of libraries, target files (object file) for each application, and executable files or scripts (script) that are not commonly used by the general user. Some software provides special commands to set up the server, which are not often operated by the system administrator, and will be placed in this directory. Note that if you are using a x86-64 Linux system, there may be/usr/lib64 directory generated

/usr/local

The system administrator installs its own downloaded software (non-distribution default provider) on the machine, and recommends installing to this directory, which is easier to manage. /usr/local, this directory is also a subdirectory with Bin,etc,include,lib

/usr/sbin

System commands that are required for non-system normal operation. The most common are service commands for some Web server Software (daemon)

/usr/share

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

A./usr/share/man: Re-line Help file

B./usr/share/doc: Description of software miscellaneous documents

C./usr/share/zoneinfo: Time zone files related to time zones

/usr/src

General source code is recommended to place here, as for the kernel source code is recommended to be placed in the/usr/src/linux/directory

3 . The meaning and content of/var

if /usr is a directory that occupies a larger hard disk capacity during installation,/var is a directory that will gradually take up hard disk capacity after the system is running. Because the/var directory is primarily for files with normal changes, including cache, login files (log file), and files generated by some software operations, including program files (lock file, run file), or such as MySQL database files.

Directory

File contents should be placed

/var/cache

Some of the staging files that are generated during the run of the application itself

/var/lib

The program itself executes the process that needs to be used to place the data file in the directory. In this directory the respective software should have its own directory. For example, the MySQL database is placed in/var/lib/mysql/, and the RPM database is placed in the/var/lib/rpm directory

/var/lock

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 error conditions, so you have to lock the device (lock), to ensure that the device will only be used for a single software

/var/log

This is the System log directory. More important documents inside such as/var/log/messages,/var/log/wtmp (log the information of the login), etc.

/var/mail

The directory where personal e-mail is placed, but this directory is also placed in the/var/spool/mail/directory. Usually these two directories are mutually connected files

/var/run

After some programs or services are started, their PID will be placed in this directory

/var/spool

This directory usually places some queue data, so-called "queues" are queues of data that are queued for use by other programs, which are usually deleted after they are used. For example, the system receives a new new piece that will be placed in the/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, it will be put in the/var/spool/mqueue, and will be removed after being sent out.

about The Linux directory structure Configuration standards introduced here, interested children's shoes can challenge FHS official English document (Https://pan.baidu.com/s/1oK7X3AHVSzn7DVzy0bfNQQ)

Linux directory structure detailed

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.