Tech Support Notes

dpkg

Dpkg is a tool to install, build, remove and manage Debian packages. The primary and more user friendly front-end for dpkg is aptitude.
Important flags

-i = install
-r = Remove package but keep configuration
-P = Remove/Delete everything including configuration files
-l = List all installed packages, along with package version and short description
-S = Find what package owns the file
-s = Check if package is installed and status
-L, --listfiles = List files installed to your system from package-name

List all packages

This will output every package installed so it is best paired with grep

[gitlab] (~) >>> dpkg -l|grep sudo
ii  sudo                                 1.8.3p1-1ubuntu3.6                Provide limited super user privileges to specific users

Find package version and short description

[solaris] (~) >>> sudo dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                  Version               Description
+++-=====================-=====================-==========================================================
ii  apache2               2.2.14-5ubuntu8.11    Apache HTTP Server metapackage

[solaris] (~) >>> dpkg -L apache2
/.
/usr
/usr/share
/usr/share/bug
/usr/share/bug/apache2
/usr/share/bug/apache2/control
/usr/share/doc
/usr/share/bug/apache2/script
/usr/share/doc/apache2

Find what package owns a file

[solaris] (~) >>> dpkg -S /usr/bin/dig
dnsutils: /usr/bin/dig

Find out if a package is installed or not

[solaris] (~) >>> dpkg -s lsof | grep Status
Status: install ok installed

Remove/Delete an installed package except configuration files

If you want to remove the configuration files as well make sure to user the -P (for purge) flag:

[gitlab] (~) >>> dpkg -r jwhois
(Reading database ... 102422 files and directories currently installed.)
Removing jwhois ...
Processing triggers for install-info ...
Processing triggers for man-db ...

[gitlab] (~) >>> grep whois /etc/

[gitlab] (~) >>> ls /etc/|grep whois
jwhois.conf

[gitlab] (~) >>> dpkg -P jwhois
(Reading database ... 102396 files and directories currently installed.)
Removing jwhois ...
Purging configuration files for jwhois ...

[gitlab] (~) >>> ls /etc/|grep whois
[gitlab] (~) >>> 

Install a local .deb file using the -i flag.

For the sanity of my <pre> code tags I added the -q (or quiet option)

[gitlab] (~/test) >>>  wget -q http://mirrors.kernel.org/ubuntu/pool/universe/j/jwhois/jwhois_4.0-2_amd64.deb

[gitlab] (~/test) >>> dpkg -i jwhois_4.0-2_amd64.deb
Selecting previously unselected package jwhois.
(Reading database ... 102394 files and directories currently installed.)
Unpacking jwhois (from jwhois_4.0-2_amd64.deb) ...
Setting up jwhois (4.0-2) ...
Adding group `jwhois' (GID 111) ...
Done.
Processing triggers for man-db ...
Processing triggers for install-info ...

Reconfigure

Reconfigures packages after they have already been installed. Pass it the names of a package or packages to reconfigure. It will ask configuration questions, much like when the package was first installed.

Additional Guides

Cheat sheet for dpkg

15 Practical Examples of “dpkg commands” for Debian Based Distros