There are two ways to file links in Linux, one is hard link, also referred to as rigid links, the other is symbolic link, also known as symbolic link. To differentiate between the two, review the common Linux ext2 file system. This filesystem uses inode and block, where Inode records the block number stored in the file data, and block is used to store the data. As for the further file system, partition disk, block Group,meta data What does not speak here, interested classmates see "bird Brother's Linux private dishes."
The hardware of the hard disk is segmented with inode and block, but how our intuitively visible catalog is stored on the hard disk. Here we want to see the directory also as a file, the hard disk will be allocated an inode and block, if it is the root directory of the file system, the general allocation of Inode number 2, to facilitate the system startup search. The file name and the corresponding inode number in the next level of the directory are stored in the block corresponding to the inode of the directory. In particular, the directory is a tree-shaped structure. The Inode and block we're talking about here correspond to only one layer of the tree.
As shown in, root is a directory that corresponds to an inode, which stores the inode and the file name and directory name of the File1,file2 and Direction1, but does not store the Inode and file name for File3 and File4. So each directory corresponds to an inode and a block, and only stores the files and directories within one layer below it. Only with the following files can be viewed by opening direction1 inode corresponding to block. This chained relationship between directories is called mounting. The direction1 is mounted in the root directory.
With this understanding, we look at what is hard links and symbolic links. First, attach two pictures of Uncle Bird (invasion and deletion)
The difference between the two is that the newly created directory name corresponds to what the inode points to, a hard link to the file data corresponding to the inode, and a symbolic link to the inode of the directory where the file name resides. Further, the hard link points to the data, and the symbolic link points to the directory. This different linking method directly affects the number of file Inode nodes. A hard link increases the number of file Inode nodes, but the symbolic link does not affect it. If we delete a hard link, the data will not be deleted as long as the number of inode connections is not 0. Other hard links can also be linked to the data. However, the symbolic link only connects to the location of the file name, and does not increase the number of Inode nodes for the file. If we delete the original file name and make the Inode node number 0 (no other hard links), the data is deleted. Although the symbolic link still exists, the data cannot be called.
Linux file links hard link and symbolic link