Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am somewhat confused what the differences between a softlink, and a hardlink are (on unix).

It seems like a softlink is the same as a shortcut in windows or an alias on Mac OS X. (Can someone confirm this?) Softlinks can link to both directories and files.

I am uncertain of what a hardlink does or if it is useful..

Is it better to use one instead of the other?


share|improve this question
This may have been done before on Super User, I know it has on Server Fault:… . BTW-- A Mac OS alias is a more complicated beast than a symlink, which is pretty simple. I don't know about windows. – dmckee Mar 8 '10 at 17:42
up vote 4 down vote accepted

Hard links can work only on the same file system. They are basically different names for one and the same group of data (file). I.e. if you create hard link to a file, and then you delete the original file, the link will continue to exists, and the data will be accessible trough the hard link. The disk space is released when the last hardlink is deleted. Actually, there's no difference between the original file and the hardlink you created later. They are interchangeable. After creating a hardlink, there's no more "original" and "link".

Softlinks can be used between different file systems, i.e. a link can be created in filesystem2 to link to a file/dir on filesystem1. Also, if you remove the original, the link becomes broken, as it points to a undefined location.

Yes, you can think about softlinks as a "shorcuts" in windows, but they are not exactly the same. Shortcut in windows is a file by itself, and if a program can not interpret them, it can not use them.

Here is a nicely pictured article on the topic :)

share|improve this answer
Awesome answer! Thanks for the links. The picture is especially helpful. – sixtyfootersdude Mar 8 '10 at 18:57
Soft link in unix like systems are also independent files (they take up an inode, they can be hard linked together, and so on), and also require interpertation (though the OS provides an API to do this). – dmckee Mar 8 '10 at 20:08
dmckee: Symlinks are interpreted by the OS when you open or stat() them. – grawity Mar 8 '10 at 21:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .