]> git.ipfire.org Git - thirdparty/util-linux.git/blob - misc-utils/hardlink.1
hardlink: cleanup man page
[thirdparty/util-linux.git] / misc-utils / hardlink.1
1 .\" SPDX-License-Identifier: MIT
2 .\"
3 .\" Copyright (C) 2008 - 2012 Julian Andres Klode. See hardlink.c for license.
4 .\" Copyright (C) 2021 Karel Zak <kzak@redhat.com>
5 .\"
6 .TH HARDLINK 1 "February 2021" "util-linux" "User Commands"
7 .SH NAME
8 hardlink \- link multiple copies of a file
9 .SH SYNOPSIS
10 .B hardlink
11 [ options ]
12 .RI [ directory | file ]...
13 .SH DESCRIPTION
14 .B hardlink
15 is a tool which replaces copies of a file with hardlinks, therefore saving
16 space.
17 .SH OPTIONS
18 .TP
19 .BR \-h ,\ \-\-help
20 print quick usage details to the screen.
21 .TP
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.
25 .TP
26 .B \-n ,\ \-\-dry\-run
27 Do not act, just print what would happen
28 .TP
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.
33 .TP
34 .BR \-p ,\ \-\-ignore\-mode
35 Link/compare files even if their mode is different. This may be a bit unpredictable.
36 .TP
37 .BR \-o ,\ \-\-ignore\-owner
38 Link/compare files even if their owner (user and group) is different. It is not
39 predictable
40 .TP
41 .BR \-t ,\ \-\-ignore\-time
42 Link/compare files even if their time of modification is different. You almost
43 always want this.
44 .TP
45 .BR \-X , \-\-respect\-xattrs
46 Only try to link files with the same extended attributes.
47 .TP
48 .BR \-m ,\ \-\-maximize
49 Among equal files, keep the file with the highest link count.
50 .TP
51 .BR \-M ,\ \-\-minimize
52 Among equal files, keep the file with the lowest link count.
53 .TP
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.
58 .TP
59 .BR \-x ,\ \-\-exclude\ \fIregex\fP
60 A regular expression which excludes files from being compared and linked.
61 .TP
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.
66 .TP
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").
72 .SH ARGUMENTS
73 .B hardlink
74 takes one or more directories which will be searched for files to be linked.
75
76 .SH BUGS
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.
80 .PP
81 .B 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.
88
89 .SH AUTHOR
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.
94
95 .SH AVAILABILITY
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/
98 Linux Kernel Archive
99 .UE .
100