1 .\" SPDX-License-Identifier: MIT
3 .\" Copyright (C) 2008 - 2012 Julian Andres Klode. See hardlink.c for license.
4 .\" Copyright (C) 2021 Karel Zak <kzak@redhat.com>
6 .TH HARDLINK 1 "February 2021" "util-linux" "User Commands"
8 hardlink \- link multiple copies of a file
12 .RI [ directory | file ]...
15 is a tool which replaces copies of a file with hardlinks, therefore saving
20 print quick usage details to the screen.
22 .BR \-v ,\ \-\-verbose
23 More verbose output. If specified once, every hardlinked file is displayed,
24 if specified twice, it also shows every comparison.
26 .B \-n ,\ \-\-dry\-run
27 Do not act, just print what would happen
29 .BR \-f ,\ \-\-respect\-name
30 Only try to link files with the same (basename). It's strongly recommended to
31 use long options rather than \fI\-f\fR which is interpreted in a different way
32 by others hardlink implementations.
34 .BR \-p ,\ \-\-ignore\-mode
35 Link/compare files even if their mode is different. This may be a bit unpredictable.
37 .BR \-o ,\ \-\-ignore\-owner
38 Link/compare files even if their owner (user and group) is different. It is not
41 .BR \-t ,\ \-\-ignore\-time
42 Link/compare files even if their time of modification is different. You almost
45 .BR \-X , \-\-respect\-xattrs
46 Only try to link files with the same extended attributes.
48 .BR \-m ,\ \-\-maximize
49 Among equal files, keep the file with the highest link count.
51 .BR \-M ,\ \-\-minimize
52 Among equal files, keep the file with the lowest link count.
54 .BR \-O ,\ \-\-keep\-oldest
55 Among equal files, keep the oldest file (least recent modification time). By
56 default, the newest file is kept. If \-\-maximize or \-\-minimize is specified,
57 the link count has a higher precedence than the time of modification.
59 .BR \-x ,\ \-\-exclude\ \fIregex\fP
60 A regular expression which excludes files from being compared and linked.
62 .BR \-i ,\ \-\-include\ \fIregex\fP
63 A regular expression to include files. If the option \-\-exclude has been given,
64 this option re-includes files which would otherwise be excluded. If the option
65 is used without \-\-exclude, only files matched by the pattern are included.
67 .BR \-s ,\ \-\-minimum\-size\ \fIsize\fP
68 The minimum size to consider. By default this is 1, so empty files will not
69 be linked. The \fIsize\fR argument may be followed by the multiplicative
70 suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB
71 and YiB (the "iB" is optional, e.g., "K" has the same meaning as "KiB").
74 takes one or more directories which will be searched for files to be linked.
77 The original hardlink implementation uses the option \fI\-f\fR to force
78 hardlinks creation between filesystem. This very rarely usable feature
79 is no more supported by the current hardlink.
82 assumes that the trees it operates on do not change during
83 operation. If a tree does change, the result is undefined and potentially
84 dangerous. For example, if a regular file is replaced by a device, hardlink
85 may start reading from the device. If a component of a path is replaced by
86 a symbolic link or file permissions change, security may be compromised. Do
87 not run hardlink on a changing tree or on a tree controlled by another user.
90 There are multiple hardlink implementations. The very first implementation is
91 from Jakub Jelinek for Fedora distribution, this implementation has been used
92 in util-linux between versions v2.34 to v2.36. The current implementations is
93 based on Debian version from Julian Andres Klod.
96 The example command is part of the util-linux package and is available from
97 .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/