Linking Files: Hard Link vs. Soft Link?

Rashkae ubuntu at
Tue Apr 14 13:40:43 UTC 2009

Amichai Rotman wrote:
> Hello,
> I have an alphabetized file hierarchy I'd like to organize into categories.
> These are all my media files - documents, video, audio etc.
> I created another hierarchy containing the categories I want and linked the
> files from the main hierarchy to the relevant category, using a soft link (*ln
> -s*).
> I realized it's a waste of space (two inodes for each file), so I thought
> re-creating the links as hard links.
> My dilemmas:
> Is it really better? - I understand that if I hard link a file, it is
> actually the same file, and if I delete the so called link I actually delete
> the real file - might be dangerous... I know I am stating the obvious, but
> I'd like your input on this (pros and cons).

Actually, it's the other way around.. Inodes aren't actually deleted
until all links to that inode are deleted... if you had 20 hard links to
a file, that file would still exist until all 20 of those links are
found and unlinked (the technical term for deleting.).  With a soft
link, however, if you delete the file, any soft-links to it become broken.

> Is there a way to create hard links with a GUI? - I am using KDE 3.5.10.
> Till now I've created half a dozen hard links using the *ln* command in CLI,
> but it will take me forever to create all those I need....

Do not know.

 Is it possible to create a hard link to a directory somehow? - when I use
> the *ln* command to link a directory, I get an error saying it is not
> possible. If that's true, the whole thing is pointless: I'd like to create a
> directory under the category hierarchy and then hard link the files under
> it. It will still mean less inodes, but it seems to me there has to be a
> way....

No, there is absolutely no way to hard link a directory.  That's not a
oversight, but a very conscientious decision made by people who spend
way to much time thinking through the implications :)

More information about the ubuntu-users mailing list