Current location - Recipe Complete Network - Food world - Why is the number of links displayed in the file 1 before creating links in linux?
Why is the number of links displayed in the file 1 before creating links in linux?

you mean the number in the ls -l output, right?

before you use ln to create a hard link for a file, the original file name points to an inode on the file system, where the contents of the file are stored. In other words, there are 1 file names pointing to the inode, so the number of links displayed by ls -l is 1.

after you create a hard link with ln, there will be *** 2 file names pointing to the same inode, so the number of links displayed by ls -l is 2. And so on.

Note that the file name of the hard link you created with ln is the same as the original file name, and there is no distinction between primary and secondary.