Linux File System Structure

Source: Internet
Author: User

Linux File System Structure

What is a file in Linux? What is its file system? Where are the configuration files? Where is the Downloaded Program saved? In Linux, does the file system have a standard structure? The hierarchical relationship between Linux file systems is briefly explained. This is useful when you are struggling to find configuration files or binary files. I have added some explanations and examples below, but "the length is long and you can check it again later ".

Another situation is that when you obtain configuration and binary files in the system, inconsistency occurs. If you are in a large organization or just an end user, this may also damage your system (for example, the binary file runs on the old library file ). If you perform security audits on your Linux system, you will find it vulnerable to various attacks. Therefore, maintaining a Clean Operating System (either Windows or Linux) is very important.

What is a Linux file?

For UNIX systems (also applicable to Linux), the following is a simple description of the file:

In UNIX systems, everything is a file; if not a file, it is a process

This definition is correct, because some special files are not just common files (such as named pipelines and sockets), but to make things easier, "Everything is a file" is also an acceptable saying. Like a UNIX system, Linux treats files and directories as the same thing, because directories are just a file that contains other file names. Programs, services, text, images, and so on are all files. For the system, basically all input and output devices are regarded as files.

Question map version history:

  • Version 2.0-17-06-2015
    • -Improved: add the title and version history
    • -Improved: Add/srv,/meida and/proc
    • -Improved: updates the description of the current Linux File System.
    • -Fixed: Multiple print errors
    • -Fixed: appearance and color
  • Version 1.0-14-02-2015
    • -Created: Basic chart
    • -Note: discard earlier versions

 

Download link

The following is a big image. If you need other formats, contact the original author. He will try to make and upload the files to a certain place for download.

  • Large image (PNG format)-2480x1755 px-184KB
  • Maximum size (PDF)-9919x7019 px-1686KB

Note: PDF files are the best choice for printing because they are of high quality.

 

Linux File System Description

In order to manage those files in an orderly manner, people are used to regard these files as an Ordered Tree Structure on the hard disk, as we are familiar with the 'Ms-DOS '(Disk Operating System) is an example. A large branch includes more branches. The branch ends are tree leaves or common files. Now we will take this tree as an example, but later we will find out why this is not a completely accurate picture.

Directory Description
/ Primary levelIs also the root directory of the entire file system hierarchy
/bin Required command binary files stored in single-user mode. All users are available, such as cat, ls, and cp.
/boot Stores Boot Loader files, such as kernels and initrd.
/dev Store necessary device files, such/dev/null
/etc Stores system-level configuration files of the host. In fact, there is a controversy about the name itself. In earlier versions of Bell's laboratory's UNIX implementation documentation,/etc indicates "Other (etcece) directories", because historically, this directory stores a variety of files that do not belong to other directories (however, the file system directory standard FSH limitation/etc is used to store static configuration files, where there should be no binary files ). After early documents were published, the directory name was redefined in different forms. Recent interpretations include redefinition such as "editable text configuration" or "Additional toolbox ".
/etc/opt Stores the configuration files of new packages./opt/.
/etc/sgml Stores configuration files, such as catalogs, for software that processes SGML
/etc/X11 X Window System 11 configuration file
/etc/xml Configuration files, such as catalogs, used for configuration files for software that processes XML (Note: Extensible Markup Language)
/home Your home directory, including saved files, personal configurations, and so on
/lib /bin/And/sbin/Required library files for the binary files in
/Lib <architecture bits> Necessary library files in the standby format. Such directories are optional, but if they exist, they must be used.
/media Mount Points of removable multimedia (such as CD-ROMs. (Appears in FHS-2.3)
/mnt Temporary mount file system
/opt Optional application software packages
/proc A virtual file system that provides process and kernel information in the form of files. In Linux, the mount point of the corresponding process File System (procfs)
/root Root user's home directory
/sbin Necessary system-level binary files, such as init, ip, and mount
/srv Site-specific data provided by the system
/tmp Temporary File (see also/var/tmp). It is usually deleted after the system is restarted.
/usr Level 2Stores users' read-only data, including (multiple) Users' main public files and Applications
/usr/bin Non-essential command binary files (not required in single-user mode); used for all users
/usr/include Standard inclusion File
/usr/lib Library file, used/usr/bin/And/usr/sbin/Binary files in
/Usr/lib <Number of architecture digits> Standby format Library (optional)
/usr/local Level 3Used for local data, specific to the host. There is usually a subdirectory,For example,bin/,lib/,share/.
/usr/local/sbin Non-essential system binary files, such as Daemon Processes for different network services
/usr/share (SHARE) Data unrelated to the architecture.
/usr/src Source code, such as the kernel source file and header file related to it
/usr/X11R6 X Window System, Version: 11, release: 6
/var A variety of Variable files, some files that continue to change with the system's regular operations, such as log files, offline files, and temporary email files
/var/cache Applications cache data. The data is generated by time-consuming I/O (input/output) or locally. These applications can regenerate or restore data. You can delete cached files when no data is lost.
/var/lib Status information. This information keeps changing as the program runs, such as the metadata of the database and software package system.
/var/lock Lock file. These files are used to track resources in use
/var/log Log File. Contains various logs.
/var/mail File containing the user's email address
/var/opt Data from additional packages will be stored in/var/opt/.
/var/run Stores information about the current system since it was last started, such as the user currently logged on and the currently running daemons (daemons ).
/var/spool This spool is mainly used to store tasks to be processed, such as print queues and outgoing mail queues.
/var/mail Outdated location for storing user email files
/var/tmp Store temporary files retained after restart

 

File Types in Linux

Most files are just common files. They are calledregularFiles; they contain common data, such as text, executable files, or programs, program input or output, etc.

Although you can think that "everything you see in Linux is a file" is quite safe, there are still some exceptions.

  • Directory: A file composed of other files
  • Special files: Used for input and output. Most special files are stored in/dev.
  • Link file: Mechanism for displaying files or directories in multiple places on the System File tree structure. We will discuss this link file in detail.
  • (Domain) socket: Special file type, which is a bit like a socket in the TCP/IP protocol. It provides network communication between processes and is protected by the access control mechanism of the file system.
  • Named Pipe: More or less like sockets (socket), it provides a communication mechanism between processes, instead of network SOCKET protocol.

 

Real-world file systems

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

Each partition has its own file system. Imagine that if we think of those file systems as a whole, we can think of a tree structure for the entire system, but this is not that simple. In a file system, a file representsinode(Index node), which is a serial number that contains the actual data information of the Build File: The data indicates who the file belongs, and its location on the hard disk.

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

Each inode represents a Data Structure on the hard disk that stores the attributes of the file, including the physical address of the file data. When the hard disk is formatted and used to store data (usually occurs during initial system installation, or when an additional hard disk is added to an existing system ), a fixed number of inodes are created for each partition. This value indicates the maximum number of files that can be stored in the partition at the same time. We usually use an inode to map 2-8 K data blocks. After a new file is generated, it obtains an idle inode. The following information is stored in the inode:

  • File owner and group owner
  • File type (conventional files, directory files ......)
  • File Permission
  • The last time the file was read and modified.
  • The time when the information was modified in inode.
  • Number of file links (see the next chapter)
  • File Size
  • Actual file data address

The only information that is not in inode is the file name and directory. They are stored in special directory files. By comparing the number of file names and inode, the system can construct a tree structure that is easy for users to understand. You can use ls-I to view the inode quantity. Inodes have independent space on the hard disk.

Via: http://www.blackmoreops.com/2015/06/18/linux-file-system-hierarchy-v2-0/

Translator: tnuoccalanosrep Proofreader: wxy

This article was originally translated by LCTT and launched with the Linux honor in China

This article permanently updates the link address:

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.