"Turn" perfectly interprets the directory structure of file systems in Linux

Source: Internet
Author: User
Tags system log

First, preface

Linux has been in contact for some time, but these days in the compilation of open source programs, only to find their own directory structure of the Linux file system is not clear enough, a lot of important directories are unclear is used to do what, so Baidu on the internet a bit about this introduction, according to their usage habits, Sort out an article about the directory structure of the Linux file system and share it with everyone.

This article explains all the directories under Linux one by one and highlights the more important directories to help beginners master the Linux directory structure. At the same time, the article concludes with a concise handbook of the Linux directory structure for everyone to check.

Second, the catalogue

1. What is a file system

2. Type of file system

3. Detailed interpretation of the catalogue structure

4, some important sub-directory interpretation

5. Appendix: Concise Reference Manual for directory structure

Third, the text

I think, not just me, for every Linux learner, understanding the directory structure of a Linux file system is a crucial step in learning Linux. Now, let's study with the flying waves .....

1. What is a file system

When you use Linux, if you go through ls–l/you will find that there are many directories, such as etc, USR, var, bin ... And so on, and in these directories, we go inside and see that there are also a lot of directories or files. The file system looks like a tree structure under Linux, so we can refer to the structure of the file system as a tree-shaped structure.

At the top of the Linux filesystem is/, we call the Linux root, which is the filesystem of the Linux operating system. The Linux file System entry is/, all directories, files, devices are in/below,/is the Linux file system Organizer, is also the most superior leader.

2. Type of file system

Linux has four basic file system types: Normal files, directory files, connection files, and special files, which can be identified by the file command.

Ordinary files: such as text files, C language meta code, shell scripts, binary executable files, etc., can be used cat, less, more, VI, Emacs to see the content, with the MV to rename.

Catalog files: Include file names, subdirectory names, and their pointers. It is the only place where Linux stores file names, and LS is used to list directory files.

Connection file: Is the directory entry that points to the same index node. With LS to see Yes, the sign of the connection file starts with L, and the file face is "--" points to the attached file.

Special files: Some Linux devices such as disks, terminals, printers, etc. are represented in the file system, then a class of files are special files, often placed in the/dev directory. For example, floppy drive A is called/dev/fd0. Linux does not have a C: concept, but instead uses/dev/had from the first hard drive.

3. Detailed explanation of the catalogue structure

Analysis of the organizational structure of the file system, what can we analyze? That is, when we list/table of contents, we see the/usr,/etc ..../var etc directory is what to do, these directories are not some specific use. No matter which version of the Linux system, there are these directories, these directories should be standard. Of course, there are some small differences between Linux distributions, but in general, they are almost the same.

To the bottom, the following will be the most important part of this article: the directory structure of the Linux file system.

/Blinux The entry of the file system and the directory at the highest level;

The commands required by the/bin system are located in this directory, such as LS, CP, mkdir and so on, and the functions and/usr/bin are similar, and the files in this directory are all executable commands that can be used by ordinary users. The most basic command required as a basic system is to put it here.

/boot Linux kernel and the file directories required for boot system programs, such as Vmlinuz initrd.img files, are located in this directory. In general, the GRUB or LILO system Boot Manager is also located in this directory;

/dev Device file storage directory, such as sound card, disk ...

/etc System configuration file location, some server configuration files are also here, such as user account and password configuration file;

/home directory is the default directory for ordinary users;

/lib Library File storage Directory

/lost+found in the ext2 or ext3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. When the system starts, the Fsck tool checks here and repairs the corrupted file system. Sometimes problems with the system, a lot of files are moved to this directory, may be repaired in a manual way, or moved to the original location of the file.

/mnt This directory is typically used to store mounted storage devices, such as CDROM directory. You can see the definition of/etc/fstab. Sometimes we can put the system boot automatically mount file system, put the mount point here is also possible. The main view is how to define the/etc/fstab, such as CD-ROM can be mounted to the/mnt/cdrom.

/OPT represents the optional meaning, and some packages are also installed here, which is the custom package, such as in Fedora Core 5.0, where OpenOffice is installed. Some of the packages we compile ourselves can be installed in this directory, and the software installed through the source package can be used through the./configure--prefix=/opt/directory.

The process information and kernel information (such as CPU, hard disk partition, memory information, etc.) are stored here when the/proc operating system is running. /proc directory masquerading file system proc mount directory, Proc is not a real file system, its definition can be see/etc/fstab.

/root the home directory for Linux super User root;

/sbin is mostly involved in system management of the command store, is super-user root executable command storage, ordinary users do not have permission to execute this directory commands, this directory and/usr/sbin; The/usr/x11r6/sbin or/usr/local/sbin directories are similar; we'll remember that all of the directories sbin contain root permissions to perform.

/tmp Temporary file directory, sometimes when users run the program, will produce temporary files. /tmp is used to store temporary files. The/var/tmp directory is similar to this directory.

/usr This is a directory of system storage programs, such as commands, help files, and so on. There are a lot of files and directories under this directory. When we install a Linux distribution that is officially provided by the package, it is mostly installed here. If a server configuration file is involved, the configuration file is installed in the/etc directory. The/usr directory includes the font directory/usr/share/fonts, help directory/usr/share/man or/usr/share/doc, normal user executable file directory/usr/bin or/usr/local/bin or/usr/ X11r6/bin, the super-user root executable command to store directories, such as/usr/sbin or/usr/x11r6/sbin or/usr/local/sbin, and the program's header file to store the directory/usr/include.

/var The content of this directory is constantly changing, see the name to know, we can understand as vary abbreviation,/var under/var/log This is used to store the system log directory. /var/www directory is to define the Apache server site storage directory,/var/lib used to store some library files, such as MySQL, as well as the storage of MySQL database;

4, some important sub-directories of the commentary

A few more common and important catalogs are added below.

/ETC/INIT.D This directory is used to store scripts that the system or server starts in System V mode, which is common in systems that are started or initialized in the mode v. such as Fedora/redhat;

/ETC/XINIT.D if the server is running in xinetd mode, its script will be placed in this directory. Some systems do not have this directory, such as Slackware, and some older versions do not. In Rehat/fedora, a newer version exists in the comparison.

/ETC/RC.D This is a directory of the Slackware distribution, which is the location of the BSD startup script, such as defining the NIC, the server opening script, etc.

/etc/x11 This is the location where the X-windows related configuration files reside.

/usr/bin This directory is a directory of executable programs, the normal user has permission to execute, when we install a program from the system's own package, most of his executable files will be placed in this directory. such as when installing the Gaim software package. Similar directories are/usr/local/bin; sometimes files in/usr/bin are/usr/local/bin linked files;

/usr/sbin This directory is also a directory of executable programs, but mostly contains commands that involve system administration. Only root privileges can be performed; similar directories are/sbin or/usr/local/sbin or/usr/x11r6/sbin, etc.;

/usr/local This directory is generally used to store the user self-compiled installation software storage directory, usually through the source package installed software, if not specifically designated installation directory, is generally installed in this directory. There are subdirectories under this directory. Check it out for yourself.

/usr/share systems are common to store things, such as/usr/share/fonts are font directories,/usr/share/doc and/usr/share/man Help files.

/USR/SRC is the kernel source directory, such as the following kernel source directory, such as Linux, linux-2.xxx.xx directory. Some systems will also install the source software package here. For example Fedora/redhat, when we install FILE.SRC.RPM, these packages will be installed in the corresponding directory/usr/src/redhat.

/var/adm such as package installation information, logs, management information, etc., in the Slackware operating system has this directory. It doesn't seem to be in fedora, so take a look.

/var/log System log storage, analysis log to see this directory of things;

/var/spool printer, mail, proxy server, such as spool directory;

5. Appendix: Concise Reference Manual for directory structure

(1) the "/" root directory section has the following subdirectories:

The/usr directory contains all commands, libraries, documents, and other files. These files will not be changed during normal operation. This directory also contains the main applications for your Linux distribution, for example, Netscape.

The/var directory contains files that were changed during normal operation: Spool files, record files, lock files, temporary files, and page format files.

The/home directory contains the user's files: parameter settings files, personalization files, documents, data, EMAIL, cached data, and so on. This directory should be maintained at the system provincial level.

The/proc directory contains all the unreal files. They do not actually exist on the disk, and they do not occupy any space. (Ls–l can be used to display their size) when viewing these files, they are actually accessing the information that exists in memory, which is used to access the system

/bin the execution files (binary) that are required for the system to be started, these files can be used by ordinary users.

/sbin System execution files (binary), these files are not intended to be used by ordinary users. (normal users can still use them, but specify a directory.) )

/etc Operating system configuration file directory.

The home directory of the/root system administrator (also called superuser or root user).

/dev Device file directory. Linux devices are treated as files, which allows the hardware to be abstracted, read-write, network-shared, and temporarily loaded into the file system. Under normal circumstances, the device will have a separate subdirectory. The contents of these devices will appear in separate subdirectories. Linux does not have a so-called driver.

/lib a shared library of programs and core modules under the root file system directory.

/boot files for the bootstrap loader (LILO or GRUB). When the computer starts (if there are multiple operating systems, it is possible to allow you to choose which operating system to start), these files are first loaded. This directory will also contain the Linux kernel (compressed file vmlinuz), but the Linux kernel can also exist elsewhere, as long as Lilo is configured and Lilo knows where the Linux kernel is.

/opt optional applications, such as KDE under REDHAT 5.2 (REDHAT 6.0, KDE in other xwindows applications, main execution program in/usr/bin directory)

/tmp temp file. The directory will be cleaned up automatically.

/lost+found files recovered during file system repair

(2) The more important parts of the "/usr" directory are:

/USR/X11R6 x-windows System (version one, release 6)

/usr/x11 with/USR/X11R6 (/USR/X11R6 's symbolic Connection)

/usr/x11r6/bin a large number of small x-windows applications (and possibly symbolic connections for large execution of files in other subdirectories).

/usr/doc Linux documentation (in the updated system, this directory is moved to/usr/share/doc).

/usr/share separate the data from your computer structure, for example, the words in a dictionary.

/usr/bin and/usr/sbin are similar to directories under the "/" root directory (/bin and/sbin), but are not used for basic booting (for example, in emergency maintenance). Most of the commands are in this directory.

/usr/local an application installed by a local administrator (or a separate subdirectory may be available for each application). After the "main" installation, this directory may be empty. Content in this directory should exist after reinstalling or upgrading the operating system.

/usr/local/bin may be a user-installed small application, and some symbolic connections to large applications in the/usr/local directory.

(3) Contents of "/proc" directory:

/proc/cpuinfo information about the processor, such as type, manufacturer, model, and performance.

/proc/devices the list of all devices configured by the current running kernel.

/PROC/DMA The DMA channel that is currently in use. /proc/filesystems the file system that is currently running the kernel configuration.

/proc/interrupts is using the interrupt, and how many interrupts were there.

/proc/ioports the I/O port that is currently in use.

Iv. PostScript

This article is an integral part of the Linux file system and is essential for a series of documents. The purpose of this article is to provide a reference manual for Linux learners on the directory structure of the Linux file system, as described in the beginning. If there is any ambiguity, please contact flying, you can go to my message this http://www.piaoyang.org/guestbook give me a message, I will try to answer your questions. With this my book, I hope to bring you a bit of help. (T002)

"Turn" perfectly interprets the directory structure of file systems in Linux

Related Article

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.