The attributes of a Linux file or directory include the node, type, permission mode, number of links, user and user group to which the file or directory belongs, and the time when the file or directory was accessed or modified recently. The details are as follows
usels -lih
List the above information
> ls -lih
12939236190 drwxr-xr-x 3 mac staff 96B 2 19 21:47 doc
Copy the code
- Column 1: inode
- Column 2: File type and permissions
- Column 3: number of hard links
- Column 4: Owner
- Column 5: The group to which you belong
- Column 6: size of file or directory;
- Column 7: Last modified time;
- Column 8: file name or directory name
inode
Inodes are inodes in Chinese. After each storage device or partition of a storage device (such as a hard disk, floppy disk, USB disk, etc.) is formatted as a file system, it should have two parts, one is an inode and the other is a Block, which is used to store data. Inodes are used to store data such as file size, owner, user group, read and write permissions, etc. Inodes index information for each file, so you have inode values. The operating system is instructed to find the corresponding file the fastest by inode value.
Hard links
In the Linux file system, no matter what type of file is stored in the disk partition, the system assigns a number to it. This number is called the Inode Index. It is the unique identification of the file or directory in the Linux file system. With this number value, you can look up the details of the file.
Linux also allows multiple file names to point to the same Inode at the same time. This is called a hard link. Such design have one advantage is that, as long as the file’s index node also has more than one link, delete one of the link does not affect the index node itself and other entities (that is, the file is not deleted), and only when the last link to be deleted, and now has new data to be stored to disk, Then the data blocks and directory links of the deleted files will be released and the storage space will be overwritten with new data. Therefore, this mechanism can effectively prevent incorrect deletion operations.
Hard links can be linked only in the same type of file system, not across file systems. It can also link to files, not directories.
Create a hard link for the file
> ln rumen.txt rumenz.txt
> ls -lih
total 0
12940530535 -rw-r--r-- 2 mac staff 0B 2 19 23:01 rumen.txt
12940530535 -rw-r--r-- 2 mac staff 0B 2 19 23:01 rumenz.txt
Copy the code
Why create an empty directory file, the number of hard connections is 2
> mkdir rumenz
> ls -lih
12940530815 drwxr-xr-x 2 mac staff 64B 2 19 23:03 rumenz
Copy the code
The reason: the rumenz directory has it by default. And.. Directory, representing the current directory and the parent directory respectively
> ls -al rumenz
drwxr-xr-x 2 mac staff 64 2 19 23:03 .
drwxr-xr-x 3 mac staff 96 2 19 23:03 ..
Copy the code
The file type
- – : indicates a common file
- D: indicates a directory
- L: soft connection (ln -s source file link file)
- B: Block devices and other peripherals are special types of files
File permissions
- R is readable and the number permission is 4
- W is writable, and the number permission is 2
- X is executable and the numeric permission is 1
The r, W, and x permissions of each owner, group, and others must be added. For example, if the permission is -rwxrwx–, the score is:
- owner = rwx = 4+2+1 = 7
- group = rwx = 4+2+1 = 7
- others= — = 0+0+0 = 0
Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station