in LearningHard Linkwith theSymbolic Linkbefore, you need to know a little bit aboutInodewith theData Block. In theLinuxfile system, a file corresponds to aInodewith a number ofData Block. Inodewith theData Blockare identified by a number, such as30333aInode, the first20334aData Block. InodeAttributes of the file, such as the owner of the file, the owning user group, the permissions on the file, and a pointer to theData Blockthe pointer. The real content of the file is stored inData Blockin the. The contents of a file are divided into sections that are saved in differentData Blockin, throughInodeyou can find all the files corresponding to theData Block. UselsCommand and Open- I.option to view the file'sInodeNumber:
In Linux, there are two different kinds of link:
Hard Link: This link does not occupy disk space. For example, there is now a hard link named Jonathanfilehl pointing to JonathanFile.txt, in fact, Jonathanfilehl and JonathanFile.txt have the same inode. As in the following:
Symbolic Link: This link actually likes disk space. For example, there is now a symbolic link named Jonathanfilesl that points to jonathanfile.txt,jonathanfilesl and there will be separate inode and data block. The filename of the source file is saved in the symbolic link. Renaming or deleting the source file will cause symbolic link to fail. The following will prove it by example. Symbolic link is as follows:
The command to create the link is ln, and if the-s option is specified, Symbolic link will be created or hard link. To verify that you are taking up disk space, now look at the disk usage of the Jonathantestfolder folder:
Now create the hard link:ln JonathanFile.txt Jonathanfilehl
As the result shows, hard link does not take up disk space, and the inode is the same as the source file. Symbolic Link takes up disk space, create a symbolic link:ln-s JonathanFile.txt jonathanfilesl
Visible, Symbolic link does occupy disk space. Also, as mentioned above, if you modify the name of the source file or delete the source file, symbolic link will fail, but will not affect hard link:
The reason is also explained above: Symbolic link will be located through the source file name, and hard link through the inode to locate. More on the use of LN, or man a bit.