hardlink - link multiple copies of a file
hardlink [options] [directory|file]...
hardlink is a tool which replaces copies of a file with hardlinks, therefore saving space.
-h, --help
print quick usage details to the screen.
-v, --verbose
More verbose output. If specified once, every hardlinked file is displayed, if specified twice, it also shows every comparison.
-q, --quiet
Quiet mode, don’t print anything.
-n, --dry-run
Do not act, just print what would happen.
-f, --respect-name
Only try to link files with the same (base)name. It’s strongly recommended to use long options rather than -f which is interpreted in a different way by other hardlink implementations.
-p, --ignore-mode
Link and compare files even if their mode is different. Results may be slightly unpredictable.
-o, --ignore-owner
Link and compare files even if their owner information (user and group) differs. Results may be unpredictable.
-t, --ignore-time
Link and compare files even if their time of modification is different. This is usually a good choice.
-X, --respect-xattrs
Only try to link files with the same extended attributes.
-m, --maximize
Among equal files, keep the file with the highest link count.
-M, --minimize
Among equal files, keep the file with the lowest link count.
-O, --keep-oldest
Among equal files, keep the oldest file (least recent modification time). By default, the newest file is kept. If --maximize or --minimize is specified, the link count has a higher precedence than the time of modification.
-x, --exclude regex
A regular expression which excludes files from being compared and linked.
-i, --include regex
A regular expression to include files. If the option --exclude has been given, this option re-includes files which would otherwise be excluded. If the option is used without --exclude, only files matched by the pattern are included.
-s, --minimum-size size
The minimum size to consider. By default this is 1, so empty files will not be linked. The size argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
-S, --buffer-size size
The size of read buffer used when comparing file contents (default: 8KiB). This costs some additional memory but potentially reduces the amount of seek operations and therefore improve performance, especially with mechanic disk drives. Optional factor suffixes are supported, like with the -s option. This is mostly efficient with other filters (i.e. with -f or -X) and can be less efficient with -top options.
hardlink takes one or more directories which will be searched for files to be linked.
The original hardlink implementation uses the option -f to force hardlinks creation between filesystem. This very rarely usable feature is no more supported by the current hardlink.
hardlink assumes that the trees it operates on do not change during operation. If a tree does change, the result is undefined and potentially dangerous. For example, if a regular file is replaced by a device, hardlink may start reading from the device. If a component of a path is replaced by a symbolic link or file permissions change, security may be compromised. Do not run hardlink on a changing tree or on a tree controlled by another user.
There are multiple hardlink implementations. The very first implementation is from Jakub Jelinek for Fedora distribution, this implementation has been used in util-linux between versions v2.34 to v2.36. The current implementations is based on Debian version from Julian Andres Klode.
For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.
The hardlink command is part of the util-linux package which can be downloaded from Linux Kernel Archive https://www.kernel.org/pub/linux/utils/util-linux/.