Docu review done: Mon 03 Jul 2023 17:08:55 CEST

Table of content

Commands

Commandsdescription
dpkg -llists packages
dpkg -L <packagename>shows files of given package
dpkg -S <filename>searches for package containing the given file
dpkg -c <packagefile>shows content of given package
dpkg -s <packagename>shows if package is installed or not
dpkg --unpack <archive>unpacks the packagefile only
dpkg --clear-availclean current information about what packages are available
dpkg --forget-old-unavailforget uninstaled and unavailable packages
dpkg-deb -I <archive>Shows metadata from package file
dpkg-deb -x <archive> <destination>extracts the filesystem tree from a package
dpkg-deb -X <archive> <destination>extracts the filesystem tree from a package + verbose
dpkg-deb -R <archive> <destination>extracts (raw) the filesystem tree from a package and the control information
dpkg-deb -e <archive> <destination>extracts only the control information files from a package

DPKG output structure

Desired=Unknown(u)/Install(i)/Remove(r)/Purge(p)/Hold(h)
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
..  packagename    version      architecture some description

Sample of an dpkg -l output

$ dpkt -l vim
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  vim            2:8.2.1913-1 amd64        Vi IMproved - enhanced vi editor

Remove package from dpkg index

Method 1 dpkg status

The ‘best’ way to do this, is by manipulating /var/lib/dpkg/status.

That file has a sensitive syntax; Doing it the wrong way may break your package management.

This is how you would do that

Find a block that looks a little like this (The actual look may depend on the package you’re trying to make ‘invisible’):

Package: xserver-xorg-input-vmmouse
Status: install ok installed
Priority: optional
Section: x11
Installed-Size: 136
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Version: 1:12.7.0-2
Provides: xorg-driver-input
Depends: libc6 (>= 2.7), xorg-input-abi-12, xserver-xorg-core (>= 2:1.10.0-0ubuntu1~), xserver-xorg-input-mouse, udev
Description: X.Org X server -- VMMouse input driver to use with VMWare
 This package provides the driver for the X11 vmmouse input device.
 .
 The VMMouse driver enables support for the special VMMouse protocol
 that is provided by VMware virtual machines to give absolute pointer
 positioning.
 .
 The vmmouse driver is capable of falling back to the standard "mouse"
 driver if a VMware virtual machine is not detected. This allows for
 dual-booting of an operating system from a virtual machine to real hardware
 without having to edit xorg.conf every time.
 .
 More information about X.Org can be found at:
 <URL:http://www.X.org>
 .
 This package is built from the X.org xf86-input-vmmouse driver module.
Original-Maintainer: Debian X Strike Force <debian-x@lists.debian.org>

The first statement Package: <name> is where you have to look for, where <name> is the name of the package you want to remove.

Each block begins with a Package: <name> line, and ends with the next Package: line, BUT do not remove the next Package: statement!

If you keep that in mind, the package will no longer appear to be installed to dpkg; despite all the files still being available.

This is a terrible hack at best, but works just fine, I’ve done it a few times in the past myself, in a time when Ubuntu was still struggling with broken packages sometimes. I do not recommend it, it’s a last resort option.

Method 2 dpkg available info

To similarly remove the unwanted package from /var/lib/dpkg/available and to remove all of the {package}.* files from /var/lib/dpkg/info/

Find users added/created/managed by packages

Not really a dpkg comand, but related to dpkg: grep -RE '(adduser|useradd).*' /var/lib/dpkg/info --include='*inst'

Known Errors

Configure post-install script exit status 10

If you get an error looking like this (<PACKAGENAME> is of course the package name :D)

dpkg: error processing package <PACKAGENAME> (--configure):
installed <PACKAGENAME> package post-installation script subprocess returned error exit status 10

Then it is worth trying to remove the assossiated file with that beneath /var/lib/dpkg/info and perform a apt install --fix-broken for example or a dpkg --configure -a to rerun it.