Introduction to Linux File system architecture

Source: Internet
Author: User

Reprint: http://www.codeceo.com/article/linux-file-introduction.html#0-youdao-1-13607-32553cecb956bf88a1550052113e506a

What are the files in Linux? What is its file system? Where are the configuration files? Where is my downloaded program saved? is the file system in Linux a standard structure? Well, it concisely illustrates the hierarchical relationship of Linux file systems. This is useful when you are struggling to find a configuration file or a binary file.

Another situation is when you get the configuration and binaries in the system, there is an inconsistency problem, if you are in a large organization, or just an end user, this can also destroy your system (for example, binary files run on the old library file). If you do a security audit on your Linux system, you will find it vulnerable to various attacks. So it's important to keep a clean operating system, whether it's Windows or Linux. What are the Linux files?

For Unix systems (also for Linux), here is a simple description of the file:

In Unix systems, everything is a file, or a process if it is not a file

This definition is more correct, because some special files are not just ordinary files (such as named Pipes and sockets), but in order to make things easier, "everything is a document" is also an acceptable argument. Linux systems, like UNIX systems, treat files and directories as objects, because the directory is just a file that contains other filenames. Programs, services, text, pictures, etc. are all documents. For the system, the input and output devices, basically all devices, are treated as files.

Title Map version History:

    • Version 2.0–17-06-2015
      • –improved: Add title and Version history
      • –improved: Add/srv,/meida and/proc
      • –improved: Updated description that reflects the current Linux file system
      • –fixed: Printing errors in multiple places
      • –fixed: Appearance and color
    • Version 1.0–14-02-2015
      • –created: Basic Chart
      • –note: Discard the lower version
Download link

The following is a larger image. If you need another format, please contact the original author, who will try to make and upload to a place for download

    • Large image (PNG format) –2480x1755 px–184kb
    • Maximum figure (PDF format) –9919x7019 px–1686kb

Note : PDF file is the best choice for printing because it has high quality.

Linux File System Description

In order to manage those files in an orderly manner, it is customary to treat these files as an ordered tree structure on the hard disk, as is the case with the familiar "MS-DOS" (Disk operating system). The larger branches include more branches, the branches of which are the leaves of the tree or the regular files. Now we will take this tree chart as an example, but later we will find out why this is not a completely accurate picture.

Catalogue Description
/ The root of the master hierarchy and the root of the entire file system hierarchy
/bin The necessary command binaries, which are available in single-user mode, are available to all users, such as cat, LS, CP, etc.
/boot Store boot loader files, such as kernels, INITRD, etc.
/dev Store the necessary equipment files, such as/dev/null
/etc The host-specific system-level configuration file is stored. In fact, there is a controversy about its name in its own sense. In earlier versions of the UNIX implementation documentation in Bell Labs,/etc was said to be "other (etcetera) directories" because historically, this directory was a repository of files that were not part of other directories (however, the file system directory standard FSH/etc is used to store static configuration files, There should be no binary files here.) This directory name was redefined in different forms after the early documentation was published. Recent explanations include redefinition such as "Editable text configuration" or "extra toolbox"
/etc/opt The configuration file/opt/that stores the new package.
/etc/sgml Store configuration files, such as catalogs, for software that deals with SGML (Translator Note: Standard Universal Markup Language)
/etc/x11 X Window System 11 version of the configuration file
/etc/xml Configuration files, such as catalogs, for software that handles XML (translator Note: Extensible Markup Language)
/home User's home directory, including saved files, personal configuration, etc.
/lib Required library files for binary files in/bin/and/sbin/
/lib< number of architecture bits > The necessary library file for the alternate format. Such directories are optional, but if they exist, there must be a program to use them.
/media A mount point for removable multimedia (such as CD-ROMs). (appearing in FHS-2.3)
/mnt Temporary mounted File system
/opt Optional Application Package
/proc A virtual file system that provides process and kernel information as a file, in Linux, corresponding to the mount point of the process file system (PROCFS)
/root Root User's home directory
/sbin Necessary system-level binaries, such as INIT, IP, Mount
/srv System-provided site-specific data
/tmp Temporary files (see also/var/tmp). Typically removed after a system restart
/usr Two-level storage of users ' read-only data, including (multiple) user primary public files and applications
/usr/bin Unnecessary command binaries (not required in single-user mode); for all users
/usr/include Standard include file
/usr/lib Library files for binary files in/usr/bin/and/usr/sbin/
/usr/lib< number of architecture bits > Alternate format library (optional)
/usr/local Level Three is used for local data, specifically on that host. There will usually be the next subdirectory, such as bin/, lib/, share/.
/usr/local/sbin Binary files of non-essential systems, such as daemons for different network services
/usr/share Schema-Independent (shared) data.
/usr/src Source code, such as the kernel source file and the header file associated with it
/usr/x11r6 X Window System, version number: 11, release version: 6
/var A wide variety of (Variable) files, some of which continue to change as the system routinely operates, such as log files, offline files, and temporary e-mail files
/var/cache The application caches data. These data are generated locally by time-consuming I/O (input/output) or by operations. These applications are capable of regenerating or recovering data. When no data is lost, the cache file can be deleted
/var/lib status information. This information changes continuously as the program runs, such as the database, the metadata of the package system, and so on.
/var/lock Lock file. These files are used to track resources that are in use
/var/log Log files. Contains various logs.
/var/mail Contains the relevant files for the user's mailbox
/var/opt The various data from the add-in is stored in the/var/opt/.
/var/run Stores information about the current system since it was last started, such as the user currently logged in and the currently running Daemons (daemon).
/var/spool The spool is primarily used to store tasks that will be processed, such as print queues and outgoing mail queues
/var/mail Obsolete location for placing user mailbox files
/var/tmp Temporary files that are kept after a restart
File types for Linux

Most files are just plain files, they are called regular files; they contain ordinary data, such as text, executable, or program, program input or output, etc.

While you can assume that "everything you see in Linux is a file," The idea is quite safe, but there are some exceptions.

    • Directories: Files made up of other files
    • Special files: The way to input and output. Most of the special files are stored in/dev and we will discuss the issue later.
    • Link file: A mechanism that allows files or directories to appear in multiple places on the system file tree structure. We will discuss this link file in detail.
    • (domain) Sockets: Special file types, like sockets in the TCP/IP protocol, provide inter-process network communication and are protected by a file system's access control mechanism.
    • Named pipes: More or less like sockets (sockets), providing a communication mechanism between processes, rather than a network socket protocol.
File system in the real world

For most users and general system administration tasks, "files and directories are an ordered class tree structure" is acceptable. However, for a computer, it does not understand what a tree is, or what a tree structure is.

Each partition has its own file system. Imagine that if you think of those file systems as a whole, we can conceive a tree structure of the whole system, but it's not that simple. In a file system, a file represents an Inode (an index node), which is a sequence number that contains the actual data information of the build file: The data indicates who the file belongs to and where it is located on the hard disk.

Each partition has its own inode, and in different partitions of a system, files with the same inode can exist.

Each inode represents a data structure on the hard disk that holds the properties of the file, including the physical address of the file data. When a hard disk is formatted and used to store data (usually during the initial system installation process or by adding additional hard disks to an existing system), each partition creates a fixed number of inode. This value indicates that the partition can store the maximum number of files at the same time. We usually use an inode to map 2-8k blocks of data. When a new file is generated, it gets a free inode. In this inode, the following information is stored:

    • File owner and group owner
    • File types (general files, directory files ...)
    • File permissions
    • Time to create, last read, and modify files
    • The time that the information was modified in the Inode
    • The number of links to the file (see next chapter)
    • File size
    • The actual address of the file data

The only information that is not in the Inode is the file name and directory. They are stored in a special catalog file. By comparing the number of filenames and inode, the system can construct a tree structure that is easy for users to understand. Users can view the number of inode through Ls-i. On the hard drive, inodes have their own space.

Introduction to Linux File system architecture

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.