Linux: Best-practices for Hard Linking?

Solution 1:

Hard-links can be very useful when you want to have the same contents (and same permissions!) in several files on the same filesystem.

Take for example a package manager, that creates a /usr/share/doc/$packagename directory for each package that is installed and inside that directory a file called LICENSE with the license information of the package. Many packages on a typical Linux system are GPL licensed, so instead of having 200 copies of the GPL on the filesystem there could be only one copy and 199 links.

Distributed version control systems copy the whole repository on clone, there is no checkout like in svn. If several clones of the same repository are on the same filesystem they can share part of the (immutable) files by using hard links (git does this, and darcs too IIRC).

Many backup solutions also use hardlinks, like rsnapshot and backuppc.

Solution 2:

The best use I've seen of hardlinks is with rsnapshot.