dpkg command cheatsheet

<th>
  <strong>Description</strong>
</th>

<th>
  <strong>Example</strong>
</th>
<td>
  Install the package
</td>

<td>
  dpkg -i zip_2.31-3_i386.deb
</td>
<td>
  Upgrade package if it is installed else install a fresh copy of package
</td>

<td>
  dpkg -i zip_2.31-3_i386.deb
</td>
<td>
  Install all packages recursively from directory
</td>

<td>
  dpkg -R /tmp/downloads
</td>
<td>
  Remove/Delete an installed package except configuration files
</td>

<td>
  dpkg -r zip
</td>
<td>
  Remove/Delete everything including configuration files
</td>

<td>
  dpkg -P apache-perl
</td>
<td>
  List all installed packages, along with package version and short description
</td>

<td>
  dpkg -l<br /> dokg -l | less<br /> dpkg -l &#8216;*apache*&#8217;<br /> dpkg -l | grep -i &#8216;sudo&#8217;
</td>
<td>
  List individual installed packages, along with package version and short description
</td>

<td>
  dpkg -l apache-perl
</td>
<td>
  Find out files are provided by the installed package i.e. list where files were installed
</td>

<td>
  dpkg -L apache-perl<br /> dpkg -L perl
</td>
<td>
  List files provided (or owned) by the package i.e. List all files inside debian .deb package file, very useful to find where files would be installed
</td>

<td>
  dpkg -c dc_1.06-19_i386.deb
</td>
<td>
  Find what package owns the file i.e. find out what package does file belong
</td>

<td>
  dpkg -S /bin/netstat<br /> dpkg -S /sbin/ippool
</td>
<td>
  Display details about package package group, version, maintainer, Architecture, display depends packages, description etc
</td>

<td>
  dpkg -p lsof
</td>
<td>
  Find out if Debian package is installed or not (status)
</td>

<td>
  dpkg -s lsof | grep Status
</td>
Syntax
dpkg -i {.deb package}
dpkg -i {.deb package}
dpkg -R {Directory-name}
dpkg -r {package}
dpkg -P {package}
dpkg -l
dpkg -l {package}
dpkg -L {package}
dpkg -c {.Deb package}
dpkg -S {/path/to/file}
dpkg -p {package}
dpkg -s {package} | grep Status

{package} – Replace with actual package name