Linux File System Summary
Basic organizational structure
The Linux File System uses an index node (inode) to record file information.
An index node is a struct that contains information such as the length of a file, creation and modification time, permission, ownership, and location on the disk.
A file system maintains an array of index nodes. Each file or directory corresponds to the unique element in the index node array. The index number of each index node in the array is called the index node number.
The Linux File System saves the file index node number and file name in the directory at the same time. Therefore, the directory is only a table that combines the file name and its index node number, each pair of file names and index node numbers in the directory is called a connection.
An index node number corresponds to a file, but an index node number corresponds to multiple file names.
Connections are divided into soft connections and hard connections. Soft connections are also called symbolic connections.
Hard connection: the original file name and connection file name both point to the same physical address. The directory cannot have a hard connection; the hard connection cannot span the File System (different partitions cannot be crossed), and only one file is copied on the disk. The deletion of files can be successful only when the same index node is a unique connection. Therefore, hard connection can prevent unnecessary accidental deletion.
Soft connection: Use the ln-s command to establish a symbolic connection to the file. Symbolic connection is a special file in Linux. As a file, its data is the path name of the file it connects. There is no function to prevent accidental deletion. Similar to shortcuts in windows.
The Tux3 file system is expected to be merged into the Linux Kernel http://www.Linuxidc.com/Linux/2014-05/101894.htm
Distributed File System Ceph http://www.Linuxidc.com/Linux/2014-05/101393.htm
Disk File System http://www.Linuxidc.com/Linux/2014-04/100792.htm
File System http://www.Linuxidc.com/Linux/2014-04/100496.htm for mounting other NFS servers in Ubuntu 14.04
File Type
Common files: generally stream files
Directory file: Used to indicate and manage all files in the system
Connection file: used to share files in different directories
Device Files: including block device files and character device files. Block device files represent disk files and CDs. Character Device Files operate on terminals, keyboards, and other devices according to characters.
MPs Queue (FIFO) file: a method for communication between processes
Socket file: the file type is related to network communication.
File Access permission
Linux classifies file visitors into three types: Owner, user group, and other users. The owner is the user who creates the file. The user is the owner of the file created by all users. The user can allow the user group to access the user's file. Generally, users are combined into user groups. For example, all users in a certain type or project can be classified as one user group by the system administrator, A user can grant file access permissions to other members of the user group. Finally, users can open their files to all users in the system. In this case, all users in the system can access their directories or files. In this sense, all other users in the system are the other user class.
Each user has its own read, write, and execution permissions. The first set of permissions controls access to your own files, that is, the owner permission. The second set of permissions controls the user group's permission to access one of the user's files. The third set of permissions controls the permissions of all other users to access a user's files. These three sets of permissions give different types of users (I .e. owners, user groups, and other users) the read, write, and execute permissions constitute a permission group with nine types.
We can use the ls command of the-l parameter to display detailed information about the file, including permissions.
The first character is generally used to distinguish between files and directories:
D: indicates a directory. In fact, in ext2fs, a directory is a special file.
-: Indicates that this is a common file.
L: This is a symbolic link file. It actually points to another file.
B and c: Block devices and other peripheral devices, respectively. They are special files.
S, p: these files are related to the system's data structures and pipelines, which are rarely seen.
2nd ~ Each three of the 10 characters is a group. The three characters on the left indicate the owner permission, and the three characters in the middle indicate the permissions of users in the same group as the owner, the three characters on the right are the permissions of other users. These three groups contain nine characters, which indicate the following meanings:
R (Read): For a file, you have the permission to Read the file content; for a directory, you have the permission to browse the contents.
W (Write): For a file, you have the permission to add or modify the file content. For a directory, you have the permission to delete or move files in the directory.
X (eXecute): For a file, you have the permission to eXecute the file. For a directory, you have the permission to enter the directory.
| Character |
Permission |
Meaning of a file |
Meaning of directory |
| R |
Readable |
Allow viewing File Content |
Allow listing contents in a directory |
| W |
Writable |
File Content modification allowed |
Allows you to create and delete files in a directory. |
| X |
Executable |
Executable files allowed |
Allow access to directory |
In fact, there are more than these file and directory settings, as well as special permissions. Because special permissions have some "privileges", you should not enable these permissions without special requirements to avoid serious security vulnerabilities, hacker intrusion, or even system destruction !!!
S or S (SUID, Set UID): an executable file can be used with this permission to obtain the privilege to access all the system resources that the file owner can use. Pay attention to files with SUID permissions. Hackers often use this permission to attach SUID to the root account owner and open a backdoor in the system for future use.
S or S (SGID, Set GID): Set on the file, the effect is the same as SUID, except that the file owner is changed to a user group, this file allows you to access system resources that can be used by the entire user group.
T or T (Sticky): The/tmp and/var/tmp directories allow all users to temporarily access files. That is, each user has full permissions to access the files, browse, delete, and move files. However, you are prohibited from deleting files in directories that do not belong to you.
Because SUID, SGID, and Sticky occupy the position of x, they are case sensitive. When both the execution permission and SUID, SGID, and Sticky are enabled, the permission indicates that the characters are lowercase:
-Rwsr-sr-t 1 root 4096 June 23 08:17 conf
If the execution permission is disabled, the characters are capitalized:
-RwSr-Sr-T 1 root 4096 June 23 08:17 conf
This article permanently updates link: http://www.Linuxidc.com/Linux/2014-06/102930.htm