{
    "mode": "man",
    "parameter": "dpkg-divert",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/dpkg-divert/1/json",
    "generated": "2026-06-03T01:50:14Z",
    "synopsis": "dpkg-divert [option...]  command",
    "sections": {
        "NAME": {
            "content": "dpkg-divert - override a package's version of a file\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "dpkg-divert [option...]  command\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "dpkg-divert is the utility used to set up and update the list of diversions.\n\nFile diversions are a way of forcing dpkg(1) not to install a file into its location, but to\na diverted location. Diversions can be used through the Debian package scripts to move a file\naway when it causes a conflict. System administrators can also use it to override some\npackage's configuration file, or whenever some files (which aren't marked as “conffiles”)\nneed to be preserved by dpkg, when installing a newer version of a package which contains\nthose files.\n",
            "subsections": []
        },
        "COMMANDS": {
            "content": "[--add] file\nAdd a diversion for file.  The file is currently not renamed, see --rename.\n\n--remove file\nRemove a diversion for file.  The file is currently not renamed, see --rename.\n\n--list glob-pattern\nList diversions matching glob-pattern.\n\n--listpackage file\nPrint the name of the package that diverts file (since dpkg 1.15.0).  Prints LOCAL if\nfile is locally diverted and nothing if file is not diverted.\n\n--truename file\nPrint the real name for a diverted file.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "--admindir directory\nSet the administrative directory to directory.  Defaults to «/var/lib/dpkg».\n\n--instdir directory\nSet the installation directory, which refers to the directory where packages get\ninstalled (since dpkg 1.19.2). Defaults to «/».\n\n--root directory\nSet the root directory to directory, which sets the installation directory to «directory»\nand the administrative directory to «directory/var/lib/dpkg» (since dpkg 1.19.2).\n\n--divert divert-to\ndivert-to is the location where the versions of file, as provided by other packages, will\nbe diverted.\n",
            "subsections": [
                {
                    "name": "--local",
                    "content": "Specifies that all packages' versions of this file are diverted.  This means, that there\nare no exceptions, and whatever package is installed, the file is diverted. This can be\nused by an admin to install a locally modified version.\n\n--package package\npackage is the name of a package whose copy of file will not be diverted. i.e. file will\nbe diverted for all packages except package.\n",
                    "long": "--local"
                },
                {
                    "name": "--quiet",
                    "content": "Quiet mode, i.e. no verbose output.\n",
                    "long": "--quiet"
                },
                {
                    "name": "--rename",
                    "content": "Actually move the file aside (or back). dpkg-divert will abort operation in case the\ndestination file already exists.  This is the common behavior used for diversions of\nfiles from the non-Essential package set (see --no-rename for more details).\n",
                    "long": "--rename"
                },
                {
                    "name": "--no-rename",
                    "content": "Specifies that the file should not be renamed while adding or removing the diversion into\nthe database (since dpkg 1.19.1).  This is intended for diversions of files from the\nEssential package set, where the temporary disappearance of the original file is not\nacceptable, as it can render the system non-functional.  This is the default behavior,\nbut that will change in the dpkg 1.20.x cycle.\n",
                    "long": "--no-rename"
                },
                {
                    "name": "--test",
                    "content": "Test mode, i.e. don't actually perform any changes, just demonstrate.\n\n-?, --help\nShow the usage message and exit.\n",
                    "long": "--test"
                },
                {
                    "name": "--version",
                    "content": "Show the version and exit.\n",
                    "long": "--version"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "0   The requested action was successfully performed.\n\n2   Fatal or unrecoverable error due to invalid command-line usage, or interactions with the\nsystem, such as accesses to the database, memory allocations, etc.\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "DPKGROOT\nIf set and the --instdir or --root options have not been specified, it will be used as\nthe filesystem root directory (since dpkg 1.19.2).\n\nDPKGADMINDIR\nIf set and the --admindir or --root options have not been specified, it will be used as\nthe dpkg data directory.\n\nDPKGMAINTSCRIPTPACKAGE\nIf set and the --local and --package options have not been specified, dpkg-divert will\nuse it as the package name.\n\nDPKGCOLORS\nSets the color mode (since dpkg 1.18.5).  The currently accepted values are: auto\n(default), always and never.\n",
            "subsections": []
        },
        "FILES": {
            "content": "/var/lib/dpkg/diversions\nFile which contains the current list of diversions of the system. It is located in the\ndpkg administration directory, along with other files important to dpkg, such as status\nor available.\n\nNote: dpkg-divert preserves the old copy of this file, with extension -old, before\nreplacing it with the new one.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "When adding, default is --local and --divert original.distrib. When removing, --package or\n--local and --divert must match if specified.\n\nDirectories can't be diverted with dpkg-divert.\n\nCare should be taken when diverting shared libraries, ldconfig(8) creates a symbolic link\nbased on the DTSONAME field embedded in the library.  Because ldconfig doesn't honour\ndiverts (only dpkg does), the symlink may end up pointing at the diverted library, if a\ndiverted library has the same SONAME as the undiverted one.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "To divert all copies of a /usr/bin/example to /usr/bin/example.foo, i.e. directs all packages\nproviding /usr/bin/example to install it as /usr/bin/example.foo, performing the rename if\nrequired:\n\ndpkg-divert --divert /usr/bin/example.foo --rename /usr/bin/example\n\nTo remove that diversion:\n\ndpkg-divert --rename --remove /usr/bin/example\n\nTo divert any package trying to install /usr/bin/example to /usr/bin/example.foo, except your\nown wibble package:\n\ndpkg-divert --package wibble --divert /usr/bin/example.foo \\\n--rename /usr/bin/example\n\nTo remove that diversion:\n\ndpkg-divert --package wibble --rename --remove /usr/bin/example\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "dpkg(1).\n\n\n\n1.21.1                                       2025-09-09                               dpkg-divert(1)",
            "subsections": []
        }
    },
    "summary": "dpkg-divert - override a package's version of a file",
    "flags": [
        {
            "flag": "",
            "long": "--local",
            "arg": null,
            "description": "Specifies that all packages' versions of this file are diverted. This means, that there are no exceptions, and whatever package is installed, the file is diverted. This can be used by an admin to install a locally modified version. --package package package is the name of a package whose copy of file will not be diverted. i.e. file will be diverted for all packages except package."
        },
        {
            "flag": "",
            "long": "--quiet",
            "arg": null,
            "description": "Quiet mode, i.e. no verbose output."
        },
        {
            "flag": "",
            "long": "--rename",
            "arg": null,
            "description": "Actually move the file aside (or back). dpkg-divert will abort operation in case the destination file already exists. This is the common behavior used for diversions of files from the non-Essential package set (see --no-rename for more details)."
        },
        {
            "flag": "",
            "long": "--no-rename",
            "arg": null,
            "description": "Specifies that the file should not be renamed while adding or removing the diversion into the database (since dpkg 1.19.1). This is intended for diversions of files from the Essential package set, where the temporary disappearance of the original file is not acceptable, as it can render the system non-functional. This is the default behavior, but that will change in the dpkg 1.20.x cycle."
        },
        {
            "flag": "",
            "long": "--test",
            "arg": null,
            "description": "Test mode, i.e. don't actually perform any changes, just demonstrate. -?, --help Show the usage message and exit."
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "Show the version and exit."
        }
    ],
    "examples": [
        "To divert all copies of a /usr/bin/example to /usr/bin/example.foo, i.e. directs all packages",
        "providing /usr/bin/example to install it as /usr/bin/example.foo, performing the rename if",
        "required:",
        "dpkg-divert --divert /usr/bin/example.foo --rename /usr/bin/example",
        "To remove that diversion:",
        "dpkg-divert --rename --remove /usr/bin/example",
        "To divert any package trying to install /usr/bin/example to /usr/bin/example.foo, except your",
        "own wibble package:",
        "dpkg-divert --package wibble --divert /usr/bin/example.foo \\",
        "--rename /usr/bin/example",
        "To remove that diversion:",
        "dpkg-divert --package wibble --rename --remove /usr/bin/example"
    ],
    "see_also": [
        {
            "name": "dpkg",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dpkg/1/json"
        }
    ]
}