Linux File System Overview

Source: Internet
Author: User

A UNIX file is an information carrier (container) that consists of a sequence of bytes, and the kernel does not interpret the contents of the file.

A file in a Linux file system is a collection of data that contains not only the data in the file but also the structure of the system in which all Linux users and programs see files, directories, soft links, and File Protection information.

Linux's earliest file system was minux, but the file system specifically designed for Linux---Extended File System Second Edition (EXT2) was designed and added to Linux, which had a significant impact on Linux.

Common file systems for Linux
    • EXT2:EXT2 Upgrade version ext3 is the Linux default file system

    • Swap: Used as a swap partition, when installing a Linux system, you must establish

    • VFAT: Compatible with Windows operating system, mainly FAT16, FAT32

    • NFS: Network File system, is unique to Linux, convenient for the sharing of files in the LAN, can realize multiple hosts sharing a host file system

Hard links and soft links

Command format:

$ ln P1 P2

Used to create a new hard link that creates a hard link with a path named P2 for the file identified by path P1.

Hard links are limited in two ways
    • Users are not allowed to create hard links to directories. Because this may turn the tree into a ring tree, it is impossible to locate a file by its name.

    • Links can only be created between files in the same file system. This is a big limitation because modern UNIX systems may contain multiple file systems that are located on different disks and/or partitions, and users cannot know the physical division between them.

Soft links (soft link) [also known as Symbolic links (symbolic link)]

Symbolic links are short files that contain any path name that has another file. The path name can point to any file or directory located on any file system, or even to a nonexistent file.

Command format:

$ ln-s P1 P2

Create a new soft link with a path named P2, P2 point to the pathname P1.

Linux directory structure

The Linux file system uses a hierarchical tree-like structure, where the top level of the structure is the root directory "/", and then the other directories are created under the root directory.

The file or directory name consists of any sequence of ASCII characters except "/" and the null character "s" (some operating systems allow the file name to be represented in a variety of egos, for example: Unicode). Most file systems have a limit on the length of filenames, usually no more than 255 characters.

There is only one directory tree in Linux that manages several disk partitions, regardless of the operating system. Structurally, a tree-type directory on a disk partition is not necessarily tied.

The role of the common directory
    • /root directory

    • /bin command to save directories (commands that ordinary users can read)

    • /boot directory to start related files

    • /dev Device File save directory

    • /etc configuration File Save Directory

    • Home directory for normal users

    • /lib System Library Save Directory

    • /MNT System Mount Directory

    • /media Mount Directory

    • /root home directory for super users

    • /tmp Temp directory

    • /sbin command to save directory (a directory that can be used by super users)

    • /proc write directly to memory

    • /sys

    • /USR system software Resources directory

      /usr/bin system command (normal user)
      /usr/sbin system command (super User)
      /usr/include: Standard header file
      /USR/SRC: Kernel source code
    • /var system related document content

In the bin and sbin,usr directories under the root directory, both bin and sbin, these four directories are used to save system commands.

The proc and SYS directories cannot be directly manipulated, and both directories hold the memory overload points.

Linux file types
  • Normal file: Usually a streaming file.

    ls -lh yan.test1: yan.test
  • Catalog files: Used to represent and manage all files in the system

    ls -lhdrwxr24: Yanlei
  • Linked files: For sharing files in different directories

    ls -18: Yan.softlink- yan.test
  • Device files: include block device files and character device files

    B Stands for block (block) devices, C for character (character) devices

    ls -la/dev/ttycrw150:/ Dev/tty
  • Pipeline (PIPE,FIFO) file: A way to provide interprocess communication


  • Socket file: This file type is related to network traffic

    ls -lh/var/lib/mysql/10:/var/lib/mysql/ Mysql.sock
File descriptors and Index nodes

UNIX provides a clear distinction between the contents of a file and the information it describes. In addition to device files and special file system files, each file consists of a sequence of characters.

All information required by the file system to process files is contained in a data structure called an index node (inode). Each file has its own index node, and the file system identifies the file with an index node.

The file system provides at least the following attributes specified in the POSIX standard:

    • File type

    • Number of hard links associated with the file

    • File length in bytes

    • Device identifiers

    • The index node number that represents the file in the file system

    • UID of owner of File

    • User group ID of the file

    • Several timestamps that indicate the change in the state of the index node, the last access time, or the last modified time

    • Access rights and File modes

Access rights and File modes

There are three types of potential users of the file

    • User as the owner of the file

    • Same group of users, not including owner

    • All remaining users (others)

There are three types of access rights---read, write, execute, and each group of users has these three permissions.

Partition

In the Windows operating system, the physical address is first separated, and then the directory is established on the partition. In the Windows operating system, all paths start with a drive letter, such as C:\Program file.

Linux, in contrast, is preceded by a directory, which then maps the physical address to the directory. In the Linux operating system, all paths are started from the root directory. The Linux default is divided into 3 partitions, the boot partition, the swap partition, and the root partition, respectively.

Mount

The partition under Linux needs to be mounted to the directory before it can be used, and the meaning of the mount is to place the contents of the partition in a directory. The process that corresponds to the directory and partition is called Mount (Mount) and the location of this mount in the file tree is the mount point.

When you want to use a device, such as to read a formatted partition, disc, or software on your hard disk, you must first map these devices to a directory, which is called a mount point, so that you can read the devices and screen out the physical partition details. The user has only the unified logic concept, all things are files.

Resources:

Deep understanding of the Linux kernel Daniel P.bovet & Marco Cesati

Linux File System Overview

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.