Ubuntu – Not design having the softlink (symlink) and hardlink in the same “link”

hard linksymbolic-link

I haven't used hardlinks for a long time and never really needed them until I was asked in an interview. I read their difference from symlinks here: What is the difference between a hard link and a symbolic link?

Is there any particular reason why the design is not having both of the capabilities of the symlink and the capabilities of the hardlink in the same link file?

You want to point to a file. Ok so you start with a hardlink functionality to cover situations where the filename is changed or the file is moved. If hardlink is not valid because it refers outside the filesystem or fails for some other reason have a fallback, the filepath of that file to refer to, in other words have a symlink.

Because what the user of an operating system wants by the end of the day is just have a link to a file.

Is there anything that could prevent the above design solution for links?

Best Answer

  • I see the following disadvantages:

    • with hard links there is no "original" path of the file anymore, i.e. you can't distinguish a file from its links. I often use links as shortcuts to files which are down in a well-sorted, nested directory structure, to simplify navigation, but I still want to be able to look up where exactly the file is stored (since its original path contains information).
    • The fallback would make things confusing for less advanced users. If you get used to everything being hardlinked, and the file being a link itself, you might sometimes delete the file at the original location because you know that the links will keep the data on the drive. Now if the fallback to a soft link has occurred, you will delete your data. Of course the software could issue a warning, but for many that could increase confusion.

    In general I don't think it's a good idea to hide fundamentally different things from the user. For most scenarios, soft links are fine. In my experience, hard links are mainly useful for backups. For example dirvish makes use of them.