Contents
Do hard links save space?
Classic hard links This can save you a lot of disk space, because otherwise you’d need to copy the file’s data. Unlike soft links, for hard links, it’s impossible to tell which of them is the original file and which is a reference , because all hard links to the same area on disk are indistinguishable from each other.
How do you tell if a link is soft or hard?
A symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of the original file. If you delete the original file, the soft link has no value, because it points to a non-existent file.
How to know if a file has more than one hard link?
If you see that a file has more than one link count, you may get curious about the other hard links associated with it. One way to find that is using the inode number of the file. You can use the ls -i command or the stat command to get the inode number.
What’s the difference between soft links and hard links?
You can see the inode numbers of files using the -i switch to the ls command. A soft link, on the other hand, points to another file by its file name. If you move or delete the original file, the link will be broken. With reference to the part of the question that asked, “why would I want to use hard links at all?”:
What does the number of hard links mean?
Now, hard links between directories don’t exist, so the interpretation of the term “number of hard links” is a bit different than with ordinary files. In this case, the number represents how many other directories ‘link to’ it. Specifically, that means the parent directory and all directories immediately below.
What happens if I delete two hard links?
So given a file with 2 hard links, if you delete either link, the data will not be deleted. Only if you delete both will the data be gone. You can see the inode numbers of files using the -i switch to the ls command. A soft link, on the other hand, points to another file by its file name.