dpkg-divert(1)
๐ dpkg-divert(1) โ the dpkg suite's own lil file-relocation queen ๐
okay so this is the manual page for dpkg-divert, straight out of the dpkg suite, and bestieโฆ she's lowkey iconic once you get what she does. let's get into it ๐ซถ
โจ NAME โจ
dpkg-divert โ override a package's version of a file ๐
โจ SYNOPSIS โจ
dpkg-divert [option...] command
like, options first, then command. that's the whole shape of it, no cap. ๐
โจ DESCRIPTION โจ
dpkg-divert is the utility that sets up and updates the list of diversions. that's literally her whole job, and she does it slayfully.
so what's a file diversion? it's a way of forcing dpkg(1) not to install a file into its usual location, but into a diverted location instead, mwah. ๐ฆ
and where does this come in handy? listen:
- package maintainer scripts can use diversions to move a file away when it's causing a conflict ๐ญ
- system administrators can also use it to override some package's configuration file ๐
- or whenever some files need to be preserved by
dpkgwhen installing a newer version of a package which contains those files โ specifically files that aren't marked as "conffiles", iykyk
โจ COMMANDS โจ
[--add] fileโ add a diversion for file. the file is currently not renamed, see--rename. so like, it's just a bookkeeping entry rn, the actual moving is a whole separate vibe โจ--remove fileโ remove a diversion for file. same deal, the file is currently not renamed, see--rename. ๐--list [glob-pattern]โ list all diversions, or just the ones matching glob-pattern. filtered slay ๐--listpackage fileโ print the name of the package that diverts file. printsLOCALif file is locally diverted, and nothing if file is not diverted. not me leaving you on read ๐ถ
supported since dpkg 1.15.0 โญ
--truename fileโ print the real name for a diverted file. the glow-up reveal ๐ฆ
โจ OPTIONS โจ
--admindir directoryโ set the administrative directory to directory. defaults to ยซ/var/lib/dpkgยป ifDPKG_ADMINDIRhas not been set. ๐๏ธ--instdir directoryโ set the installation directory, which is the directory where packages get installed. defaults to ยซ/ยป ifDPKG_ROOThas not been set.
supported since dpkg 1.19.2 ๐ธ
--root directoryโ set the root directory to directory, which sets the installation directory to ยซ*directory*ยป and the administrative directory to ยซ*directory*/var/lib/dpkgยป ifDPKG_ROOThas not been set.
supported since dpkg 1.19.2 ๐ธ
--divert divert-toโ divert-to is the location where the versions of file, as provided by other packages, will be diverted. the new address bestie is moving to ๐ก--localโ specifies that all packages' versions of this file are diverted. that means there are zero exceptions: whatever package is installed, the file is diverted. an admin can use this 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. it's giving main character exception energy ๐--quietโ quiet mode, i.e. no verbose output. shhh ๐คซ--renameโ actually move the file aside (or back).dpkg-divertwill abort the 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-renamefor more details). โ ๏ธ--no-renameโ specifies that the file should not be renamed while adding or removing the diversion into the database. 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, which will change once there are no known users, but not before the dpkg 1.23.x release cycle.
supported since dpkg 1.19.1 ๐ง
--testโ test mode, i.e. don't actually perform any changes, just demonstrate. dress rehearsal vibes ๐ญ-?,--helpโ show the usage message and exit. ๐ซถ--versionโ show the version and exit. ๐
โจ EXIT STATUS โจ
0โ the requested action was successfully performed. ate and left no crumbs ๐2โ fatal or unrecoverable error due to invalid command-line usage, or interactions with the system, such as accesses to the database, memory allocations, etc. ๐ not the vibe.
โจ ENVIRONMENT โจ
DPKG_ROOTโ if set and the--instdiror--rootoptions have not been specified, it will be used as the filesystem root directory.
supported since dpkg 1.19.2 ๐
DPKG_ADMINDIRโ if set and the--admindiror--rootoptions have not been specified, it will be used as the dpkg data directory. ๐๏ธDPKG_MAINTSCRIPT_PACKAGEโ if set and the--localand--packageoptions have not been specified,dpkg-divertwill use it as the package name. ๐ท๏ธDPKG_DEBUGโ sets the debug mask from an octal value. the currently accepted flags are described in thedpkg --debugoption, but not all these flags might have an effect on this program.
supported since dpkg 1.21.10 ๐
DPKG_COLORSโ sets the color mode. the currently accepted values are:auto(default),alwaysandnever. aesthetic choices, we love to see it ๐จ
supported since dpkg 1.18.5 ๐ธ
DPKG_NLSโ if set, it will be used to decide whether to activate Native Language Support, also known as internationalization (or i18n) support. the accepted values are:0and1(default). ๐
supported since dpkg 1.22.7 ๐
โจ FILES โจ
/var/lib/dpkg/diversionsโ the file which contains the current list of diversions of the system. it lives in the dpkg administration directory, along with other files important to dpkg, such asstatusoravailable. ๐
note:dpkg-divertpreserves the old copy of this file, with extension-old, before replacing it with the new one. she's sentimental like that ๐ฅบ๐
โจ NOTES โจ
when adding, the default is --local and --divert original.distrib. when removing, --package or --local and --divert must match if specified. matching sets only, bestie ๐ฏ
Directories can't be diverted with dpkg-divert. periodt. ๐ซ๐
and pls be careful when diverting shared libraries ๐ญ โ ldconfig(8) creates a symbolic link based on the DT_SONAME field embedded in the library. because ldconfig does not honor diverts (only dpkg does), the symlink may end up pointing at the diverted library, if a diverted library has the same SONAME as the undiverted one. likeโฆ the link is gonna follow the wrong twin, be so serious โ ๏ธ
โจ EXAMPLES โจ
to divert all copies of a /usr/bin/example to /usr/bin/example.foo โ i.e. this 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 how the remove mirrors the add? that's the matching rule in action, iykyk ๐
โจ SEE ALSO โจ
dpkg(1). that's the one and only ๐ฅ
okay that's the whole page bestie, and before you go โ this fine piece of documentation is from the dpkg suite, version 1.23.11-dirty, dated 2026-09-09. go forth and divert responsibly ๐
โจ๐ฆ
๐ฆ where this page comes from
- arch rolling: dpkg 1.23.11-1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms