{
    "mode": "man",
    "parameter": "hardlink",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/hardlink/1/json",
    "generated": "2026-06-02T23:35:20Z",
    "synopsis": "hardlink [options] [directory|file]...",
    "sections": {
        "NAME": {
            "content": "hardlink - link multiple copies of a file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "hardlink [options] [directory|file]...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "hardlink is a tool which replaces copies of a file with hardlinks, therefore saving space.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-h --help",
                    "content": "print quick usage details to the screen.\n",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-v --verbose",
                    "content": "More verbose output. If specified once, every hardlinked file is displayed, if specified\ntwice, it also shows every comparison.\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "-q --quiet",
                    "content": "Quiet mode, don’t print anything.\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-n --dry-run",
                    "content": "Do not act, just print what would happen.\n",
                    "flag": "-n",
                    "long": "--dry-run"
                },
                {
                    "name": "-f --respect-name",
                    "content": "Only try to link files with the same (base)name. It’s strongly recommended to use long\noptions rather than -f which is interpreted in a different way by other hardlink\nimplementations.\n",
                    "flag": "-f",
                    "long": "--respect-name"
                },
                {
                    "name": "-p --ignore-mode",
                    "content": "Link and compare files even if their mode is different. Results may be slightly\nunpredictable.\n",
                    "flag": "-p",
                    "long": "--ignore-mode"
                },
                {
                    "name": "-o --ignore-owner",
                    "content": "Link and compare files even if their owner information (user and group) differs. Results\nmay be unpredictable.\n",
                    "flag": "-o",
                    "long": "--ignore-owner"
                },
                {
                    "name": "-t --ignore-time",
                    "content": "Link and compare files even if their time of modification is different. This is usually a\ngood choice.\n",
                    "flag": "-t",
                    "long": "--ignore-time"
                },
                {
                    "name": "-X --respect-xattrs",
                    "content": "Only try to link files with the same extended attributes.\n",
                    "flag": "-X",
                    "long": "--respect-xattrs"
                },
                {
                    "name": "-m --maximize",
                    "content": "Among equal files, keep the file with the highest link count.\n",
                    "flag": "-m",
                    "long": "--maximize"
                },
                {
                    "name": "-M --minimize",
                    "content": "Among equal files, keep the file with the lowest link count.\n",
                    "flag": "-M",
                    "long": "--minimize"
                },
                {
                    "name": "-O --keep-oldest",
                    "content": "Among equal files, keep the oldest file (least recent modification time). By default, the\nnewest file is kept. If --maximize or --minimize is specified, the link count has a\nhigher precedence than the time of modification.\n",
                    "flag": "-O",
                    "long": "--keep-oldest"
                },
                {
                    "name": "-x --exclude",
                    "content": "A regular expression which excludes files from being compared and linked.\n",
                    "flag": "-x",
                    "long": "--exclude"
                },
                {
                    "name": "-i --include",
                    "content": "A regular expression to include files. If the option --exclude has been given, this\noption re-includes files which would otherwise be excluded. If the option is used without\n--exclude, only files matched by the pattern are included.\n",
                    "flag": "-i",
                    "long": "--include"
                },
                {
                    "name": "-s --minimum-size",
                    "content": "The minimum size to consider. By default this is 1, so empty files will not be linked.\nThe size argument may be followed by the multiplicative suffixes KiB (=1024), MiB\n(=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the \"iB\" is optional, e.g.,\n\"K\" has the same meaning as \"KiB\").\n",
                    "flag": "-s",
                    "long": "--minimum-size"
                },
                {
                    "name": "-S --buffer-size",
                    "content": "The size of read buffer used when comparing file contents (default: 8KiB). This costs\nsome additional memory but potentially reduces the amount of seek operations and\ntherefore improve performance, especially with mechanic disk drives. Optional factor\nsuffixes are supported, like with the -s option. This is mostly efficient with other\nfilters (i.e. with -f or -X) and can be less efficient with -top options.\n",
                    "flag": "-S",
                    "long": "--buffer-size"
                }
            ]
        },
        "ARGUMENTS": {
            "content": "hardlink takes one or more directories which will be searched for files to be linked.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "The original hardlink implementation uses the option -f to force hardlinks creation between\nfilesystem. This very rarely usable feature is no more supported by the current hardlink.\n\nhardlink assumes that the trees it operates on do not change during operation. If a tree does\nchange, the result is undefined and potentially dangerous. For example, if a regular file is\nreplaced by a device, hardlink may start reading from the device. If a component of a path is\nreplaced by a symbolic link or file permissions change, security may be compromised. Do not\nrun hardlink on a changing tree or on a tree controlled by another user.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "There are multiple hardlink implementations. The very first implementation is from Jakub\nJelinek for Fedora distribution, this implementation has been used in util-linux between\nversions v2.34 to v2.36. The current implementations is based on Debian version from Julian\nAndres Klode.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "The hardlink command is part of the util-linux package which can be downloaded from Linux\nKernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2026-03-06                                  HARDLINK(1)",
            "subsections": []
        }
    },
    "summary": "hardlink - link multiple copies of a file",
    "flags": [
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "print quick usage details to the screen."
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "More verbose output. If specified once, every hardlinked file is displayed, if specified twice, it also shows every comparison."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Quiet mode, don’t print anything."
        },
        {
            "flag": "-n",
            "long": "--dry-run",
            "arg": null,
            "description": "Do not act, just print what would happen."
        },
        {
            "flag": "-f",
            "long": "--respect-name",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-p",
            "long": "--ignore-mode",
            "arg": null,
            "description": "Link and compare files even if their mode is different. Results may be slightly unpredictable."
        },
        {
            "flag": "-o",
            "long": "--ignore-owner",
            "arg": null,
            "description": "Link and compare files even if their owner information (user and group) differs. Results may be unpredictable."
        },
        {
            "flag": "-t",
            "long": "--ignore-time",
            "arg": null,
            "description": "Link and compare files even if their time of modification is different. This is usually a good choice."
        },
        {
            "flag": "-X",
            "long": "--respect-xattrs",
            "arg": null,
            "description": "Only try to link files with the same extended attributes."
        },
        {
            "flag": "-m",
            "long": "--maximize",
            "arg": null,
            "description": "Among equal files, keep the file with the highest link count."
        },
        {
            "flag": "-M",
            "long": "--minimize",
            "arg": null,
            "description": "Among equal files, keep the file with the lowest link count."
        },
        {
            "flag": "-O",
            "long": "--keep-oldest",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-x",
            "long": "--exclude",
            "arg": null,
            "description": "A regular expression which excludes files from being compared and linked."
        },
        {
            "flag": "-i",
            "long": "--include",
            "arg": null,
            "description": "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."
        },
        {
            "flag": "-s",
            "long": "--minimum-size",
            "arg": null,
            "description": "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\")."
        },
        {
            "flag": "-S",
            "long": "--buffer-size",
            "arg": null,
            "description": "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."
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Consolidate duplicate files by replacing them with hard links.",
        "examples": [
            {
                "description": "Perform a dry run without modifying files",
                "command": "hardlink {{-n|--dry-run}} {{path/to/directory}}"
            },
            {
                "description": "Hardlink duplicate files in a directory",
                "command": "hardlink {{path/to/directory}}"
            },
            {
                "description": "Hardlink duplicate files in multiple directories",
                "command": "hardlink {{path/to/directory1 path/to/directory2 ...}}"
            },
            {
                "description": "Display verbose output while hardlinking",
                "command": "hardlink {{-v|--verbose}} {{path/to/directory}}"
            },
            {
                "description": "Only consider files with a minimum size",
                "command": "hardlink {{-s|--minimum-size}} {{size}} {{path/to/directory}}"
            }
        ]
    }
}