Saturday, 26 October 2019

linux - When would creating a hard link be useful?


There are basically two main limitations with hard links:



  1. Hard links normally require that the link and the file reside in the same file system.

  2. Only the superuser can create a hard link to a directory.


Thus, symbolic links were introduced to get around the limitations of hard links. So, the question is, are hard links still needed? Might there be situation where they are more useful?



Answer



Hardlinks help us organize our file system in a much more flexible way. Basically, hardlinks allow us to take one file and have it be multiple places in the filesystem at once. Think about a scenario where you are a photographer and have lots of photos (this is an example from my life!). You might organize them by the people that appear in them, because sometimes people ask you for photos of them. But you might also want to organize them by the location and by the date. There's no real way to nest these three things, they're totally separate axes of organization. So you can create three different hierarchies for these three different things, and have each photo present in all three, without having to store each photo three times. That's the magic of hardlinks. Unlink symlinks, we don't need to worry about where the "real file" is, because they're all the real file. We can delete and move at will, because the file will be retained until there are no longer any references to it, and removed when you delete the last hardlink. It's simple and doesn't require you to keep track of very much.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...