Home  >  Article  >  Operation and Maintenance  >  What is the structure of linux file system

What is the structure of linux file system

青灯夜游
青灯夜游Original
2023-03-02 10:08:298090browse

The Linux file system is a tree structure, that is, there is only one root directory, which contains information about lower-level subdirectories or files; the subdirectories can contain information about more subdirectories or files, so that one layer at a time It extends layer by layer to form an upside-down tree. The top level of the Linux file system starts with the root directory. The system uses "/" to represent the root directory. Below the root directory can be either a directory or a file, and each directory can contain (sub) Directory or file.

What is the structure of linux file system

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

The files in the Linux file system are a collection of data. The file system not only contains the data in the file but also the structure of the file system. All the files, directories, soft links and files seen by Linux users and programs Protection information etc. are stored in it.

The structure of the Linux file system

Like DOS and Windows systems, Linux also uses a tree directory structure to organize and manage files. All files are hierarchical and divided. They are organized in layers to form a tree-like hierarchical structure. In the entire tree structure, there is only one root directory located in the root partition. Other directories, files and external devices (including hard disks, floppy drives, optical drives, modems, etc.) files start from the root directory and are mounted under the root directory. , that is, the entire Linux file system starts from the root directory, and all other partitions are mounted to a directory in the directory tree. Access to these partitions can be achieved by accessing the mount point directory.

The Linux file system adopts a tree directory structure, that is, there is only one root directory, which contains information about lower-level subdirectories or files; subdirectories can contain information about more subdirectories or files. , which extends layer by layer; forming an upside-down tree. In a directory tree, both the root node and the intermediate nodes must be directories, and files can only appear as leaf nodes. Of course, directories can also be leaf nodes.

What is the structure of linux file system

The top level of the file system starts from the root directory. The system uses "/" to represent the root directory. The directory below the root directory can be , or it can be a file, and each directory can contain (sub)directories or files. Repeatedly, a huge file system can be formed.

Explanation

  • In Linux, directory names or file names are case-sensitive, such as HaiCoder, haicoder and Haicoder are 3 different directories or files.

  • The complete directory or file path is composed of a series of directory names, each directory is separated by "/".

  • In the file system, there are two special directories. One is the working directory of the user, which is the current directory, which can be represented by a dot "."; the other is the current directory. The upper-level directory, also called the parent directory, is represented by two dots "...".

  • If a directory or file name starts with a dot, it means that the directory or file is a hidden directory or file. That is, when searching in the default mode, the directory or file will not be displayed.

The contents of each subdirectory of the Linux system

Path Main content
/root Necessary files for booting the system, file system mounting information, system repair tools and backup tools, etc.
/usr Command program files, program libraries, manuals and other documents that do not need to be modified during normal operations
/var Frequently changing files, such as spool directories for printers, mail, news, etc., log files, formatted man pages and temporary files, etc.
/home The user’s home directory. User data is usually stored in this directory.
/proc The contents of the directory are the contents of the directory after the system starts. Created in memory, it contains kernel virtual file system and process information, such as CPU, DMA channel and interrupt usage information.
/etc System-related configuration Files, such as boot options, etc.
/bin Most of them are necessary commands and can be used by ordinary users
/dev The directory where various device files are located, such as CDs, U disks, hard disks, etc.
/tmp Generated during the running of the program Temporary files
/boot Files to be used by the boot loader, the kernel image is usually saved in this directory
/mnt is the mounting directory of the temporary file system, such as U disk, CD, etc. You can establish a mount point in this directory

Classification of Linux file systems

 Files are a collection of related information with names. There are many ways to classify them. They are divided into four categories under the Linux system .

1. Ordinary files

Ordinary files are also called regular files and contain strings of various lengths. Common files include the following types.
 (1) Text file

 (2) Data file

 (3) Executable binary file

You can use the file command to view the file type. The command can take any number of file names as parameters, separated by spaces. The usage method is:

file filenamel [filename2 … ]

2. Directory file

The main purpose is to manage and organize a large number of files in the system. It stores the location, size and other file-related information of a set of related files. Directory files are generally referred to as directories, including file names, subdirectory names and pointers. It is the only place where Linux stores file names, and directory files can be listed using the ls command.

3. Symbolic link files

ˆ those directory entries that point to the same index node. When viewed using the ls command, the sign of the linked file starts with the letter l, and "->" after the file points to the linked file.

4. Device file

The Linux system treats each I/O device as a file. Device files can be subdivided into block device files and character device files. The access of the former is based on character blocks, while the latter is based on single character. Some Linux devices such as disks, terminals, printers, etc. are represented in the form of files. Such files are device files and are often placed in the /dev directory.

File naming rules

 (1) The file name should be as single as possible.

 (2) Except for '/' and null characters, the file name can contain any ASCII characters, because these two characters are treated as path and special characters by the system kernel.

  (3) It is customary to use underscores and dots to distinguish file types and make file names more readable. However, the following characters should be avoided because they have special meanings for the system shell. These characters include; |〈〉, $,! ,%,&,*,? ,\,(),[]wait. ,

  (4) File names should avoid using spaces, tabs or other control characters.

  (5) In order to facilitate management and identification, similar files should use the same suffix or extension.

  (6) The system distinguishes the case of file names. File and directory names created by general users should use lowercase characters.

  (7) File names starting with a dot are hidden files. By default, they cannot be displayed on the screen using the ls command. Also, by default, Shell wildcards do not match such hidden file names.

File name wildcards

In order to process multiple files at one time, Shell provides several special characters, called file wildcards. The main ones are The following types.

  (1) Asterisk "*": matches 0 or more any characters, and can match all files in the current directory, except hidden files starting with a dot.

   (2) Question mark "?": Matches only one arbitrary character. Multiple question marks can be used. For example file? Can match file1, file2, file3 files, but does not match file, file10.

 (3) Square brackets "[ ]": only matches one of the characters in the square brackets. You can use a dash to represent a range of characters. If the square brackets start with an exclamation point, it means it does not match. Matches characters after the exclamation point.

Permissions of users in the Linux system

 Every file and directory in the Linux system has access permissions, which are used to determine what How users can access and operate the file or directory. The Linux system stipulates three different types of users based on the user's identity and login method: the file owner user (user), the same group of users (group), and other users who can access the system (others). It also stipulates that each user has three ways to access files or directories: readable files (r), writable files (w), and executable files (x).

In addition, the attributes of a Linux file or directory mainly include: the node, type, number of links, the user and user group it belongs to, the most recent access or modification time, etc. Users can view it through the ls command (the -lih option needs to be used to display complete information)

What is the structure of linux file system

Function of file and directory permissions

Read permission (r) means that only the specified user is allowed to read the contents of the corresponding file and is prohibited from making any changes to it; for example, the directory read permission means that the files stored in the directory can be listed, that is, read Directory contents.

 Write permission (w) means that the specified user is allowed to open and modify the file; for example, directory write means that it allows you to delete or create new files or directories from the directory.

Execution permission (x) means that the specified user is allowed to execute the file as a program; if the directory is executable, it means that you are allowed to search in the directory and use the cd command to switch the working directory to the directory.

 When the Linux system creates a file, it will automatically assign the read and write permissions of the file to its owner, so that the owner can display and modify the file, and can also change these permissions to other combinations.

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of What is the structure of linux file system. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn