Hard link
A hard link is a directory entry naming an existing file's inode, so multiple hard links refer to the same file rather than to separate copies.
On Linux, link() creates another name without overwriting an existing destination and cannot cross mounted-filesystem boundaries. In-place writes through either name modify the shared file; replacing one name with rename() instead rebinds that name and leaves the other hard links attached to their original inode. Removing one link does not remove the other names. Separate open() calls through these names still create separate open file descriptions.
Relations
- related
- inode, atomic-rename, unlink, open-file-description, directory-fsync
Advantages
- Provides another name for the same file without copying its contents.
Limitations
- Shared file contents mean a hard link is not an independent backup.
- Linux link() rejects directories and links across mounted filesystems.