{
    "content": [
        {
            "type": "text",
            "text": "# hardlink(1) (man)\n\n## TLDR\n\n> Consolidate duplicate files by replacing them with hard links.\n\n- Perform a dry run without modifying files:\n  `hardlink {{-n|--dry-run}} {{path/to/directory}}`\n- Hardlink duplicate files in a directory:\n  `hardlink {{path/to/directory}}`\n- Hardlink duplicate files in multiple directories:\n  `hardlink {{path/to/directory1 path/to/directory2 ...}}`\n- Display verbose output while hardlinking:\n  `hardlink {{-v|--verbose}} {{path/to/directory}}`\n- Only consider files with a minimum size:\n  `hardlink {{-s|--minimum-size}} {{size}} {{path/to/directory}}`\n\n*Source: tldr-pages*\n\n---\n\n**Summary:** hardlink - link multiple copies of a file\n\n**Synopsis:** hardlink [options] [directory|file]...\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| -h | --help | — | print quick usage details to the screen. |\n| -v | --verbose | — | More verbose output. If specified once, every hardlinked file is displayed, if specified twice, it also shows every comp |\n| -q | --quiet | — | Quiet mode, don’t print anything. |\n| -n | --dry-run | — | Do not act, just print what would happen. |\n| -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 i |\n| -p | --ignore-mode | — | Link and compare files even if their mode is different. Results may be slightly unpredictable. |\n| -o | --ignore-owner | — | Link and compare files even if their owner information (user and group) differs. Results may be unpredictable. |\n| -t | --ignore-time | — | Link and compare files even if their time of modification is different. This is usually a good choice. |\n| -X | --respect-xattrs | — | Only try to link files with the same extended attributes. |\n| -m | --maximize | — | Among equal files, keep the file with the highest link count. |\n| -M | --minimize | — | Among equal files, keep the file with the lowest link count. |\n| -O | --keep-oldest | — | Among equal files, keep the oldest file (least recent modification time). By default, the newest file is kept. If --maxi |\n| -x | --exclude | — | A regular expression which excludes files from being compared and linked. |\n| -i | --include | — | A regular expression to include files. If the option --exclude has been given, this option re-includes files which would |\n| -s | --minimum-size | — | The minimum size to consider. By default this is 1, so empty files will not be linked. The size argument may be followed |\n| -S | --buffer-size | — | The size of read buffer used when comparing file contents (default: 8KiB). This costs some additional memory but potenti |\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (2 lines)\n- **DESCRIPTION** (2 lines)\n- **OPTIONS** (1 lines) — 16 subsections\n  - -h --help (2 lines)\n  - -v --verbose (3 lines)\n  - -q --quiet (2 lines)\n  - -n --dry-run (2 lines)\n  - -f --respect-name (4 lines)\n  - -p --ignore-mode (3 lines)\n  - -o --ignore-owner (3 lines)\n  - -t --ignore-time (3 lines)\n  - -X --respect-xattrs (2 lines)\n  - -m --maximize (2 lines)\n  - -M --minimize (2 lines)\n  - -O --keep-oldest (4 lines)\n  - -x --exclude (2 lines)\n  - -i --include (4 lines)\n  - -s --minimum-size (5 lines)\n  - -S --buffer-size (6 lines)\n- **ARGUMENTS** (2 lines)\n- **BUGS** (9 lines)\n- **AUTHOR** (5 lines)\n- **REPORTING BUGS** (2 lines)\n- **AVAILABILITY** (6 lines)\n\n## Full Content\n\n### NAME\n\nhardlink - link multiple copies of a file\n\n### SYNOPSIS\n\nhardlink [options] [directory|file]...\n\n### DESCRIPTION\n\nhardlink is a tool which replaces copies of a file with hardlinks, therefore saving space.\n\n### OPTIONS\n\n#### -h --help\n\nprint quick usage details to the screen.\n\n#### -v --verbose\n\nMore verbose output. If specified once, every hardlinked file is displayed, if specified\ntwice, it also shows every comparison.\n\n#### -q --quiet\n\nQuiet mode, don’t print anything.\n\n#### -n --dry-run\n\nDo not act, just print what would happen.\n\n#### -f --respect-name\n\nOnly 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\n#### -p --ignore-mode\n\nLink and compare files even if their mode is different. Results may be slightly\nunpredictable.\n\n#### -o --ignore-owner\n\nLink and compare files even if their owner information (user and group) differs. Results\nmay be unpredictable.\n\n#### -t --ignore-time\n\nLink and compare files even if their time of modification is different. This is usually a\ngood choice.\n\n#### -X --respect-xattrs\n\nOnly try to link files with the same extended attributes.\n\n#### -m --maximize\n\nAmong equal files, keep the file with the highest link count.\n\n#### -M --minimize\n\nAmong equal files, keep the file with the lowest link count.\n\n#### -O --keep-oldest\n\nAmong 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\n#### -x --exclude\n\nA regular expression which excludes files from being compared and linked.\n\n#### -i --include\n\nA 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\n#### -s --minimum-size\n\nThe 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\n#### -S --buffer-size\n\nThe 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\n### ARGUMENTS\n\nhardlink takes one or more directories which will be searched for files to be linked.\n\n### BUGS\n\nThe 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\n### AUTHOR\n\nThere 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\n### REPORTING BUGS\n\nFor bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n\n### AVAILABILITY\n\nThe 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)\n\n"
        }
    ],
    "structuredContent": {
        "command": "hardlink",
        "section": "1",
        "mode": "man",
        "summary": "hardlink - link multiple copies of a file",
        "synopsis": "hardlink [options] [directory|file]...",
        "tldr_summary": "Consolidate duplicate files by replacing them with hard links.",
        "tldr_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}}"
            }
        ],
        "tldr_source": "official",
        "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": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-h --help",
                        "lines": 2,
                        "flag": "-h",
                        "long": "--help"
                    },
                    {
                        "name": "-v --verbose",
                        "lines": 3,
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "-q --quiet",
                        "lines": 2,
                        "flag": "-q",
                        "long": "--quiet"
                    },
                    {
                        "name": "-n --dry-run",
                        "lines": 2,
                        "flag": "-n",
                        "long": "--dry-run"
                    },
                    {
                        "name": "-f --respect-name",
                        "lines": 4,
                        "flag": "-f",
                        "long": "--respect-name"
                    },
                    {
                        "name": "-p --ignore-mode",
                        "lines": 3,
                        "flag": "-p",
                        "long": "--ignore-mode"
                    },
                    {
                        "name": "-o --ignore-owner",
                        "lines": 3,
                        "flag": "-o",
                        "long": "--ignore-owner"
                    },
                    {
                        "name": "-t --ignore-time",
                        "lines": 3,
                        "flag": "-t",
                        "long": "--ignore-time"
                    },
                    {
                        "name": "-X --respect-xattrs",
                        "lines": 2,
                        "flag": "-X",
                        "long": "--respect-xattrs"
                    },
                    {
                        "name": "-m --maximize",
                        "lines": 2,
                        "flag": "-m",
                        "long": "--maximize"
                    },
                    {
                        "name": "-M --minimize",
                        "lines": 2,
                        "flag": "-M",
                        "long": "--minimize"
                    },
                    {
                        "name": "-O --keep-oldest",
                        "lines": 4,
                        "flag": "-O",
                        "long": "--keep-oldest"
                    },
                    {
                        "name": "-x --exclude",
                        "lines": 2,
                        "flag": "-x",
                        "long": "--exclude"
                    },
                    {
                        "name": "-i --include",
                        "lines": 4,
                        "flag": "-i",
                        "long": "--include"
                    },
                    {
                        "name": "-s --minimum-size",
                        "lines": 5,
                        "flag": "-s",
                        "long": "--minimum-size"
                    },
                    {
                        "name": "-S --buffer-size",
                        "lines": 6,
                        "flag": "-S",
                        "long": "--buffer-size"
                    }
                ]
            },
            {
                "name": "ARGUMENTS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AVAILABILITY",
                "lines": 6,
                "subsections": []
            }
        ]
    }
}