package is in a very bad inconsistent state; you should reinstall it before attempting a removal

I encountered this error in the course of applying updates on an Ubuntu 16.04.5 LTS server. The error prevented the apt-get upgrade process from completing. Attempting to remove the package (dpkg --remove unattended-upgrades) failed. A quick Google search found this solution that worked.

# dpkg –remove –force-remove-reinstreq unattended-upgrades
dpkg: warning: overriding problem because –force enabled:
dpkg: warning: package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
(Reading database … 100727 files and directories currently installed.)
Removing unattended-upgrades (0.90ubuntu0.9) …
Processing triggers for man-db (2.7.5-1) …

That removed the package and then I was able to reinstall it and complete my package updates.

Display the contents of a Redhat RPM or Debian deb package

Displaying the contents of an RPM or deb package is simple. Each of these can be thought of as an archive of files plus an install script. To view the files in the archive execute the following:

Redhat rpm:


rpm -qlp package.rpm

Debian deb:

dpkg -c package.deb

For Debian/Ubuntu systems I use a program called apt-file that allows you to search for files provided by any package that is available to your system even if that package is not installed. This comes in handy if you are building a program from source that has libraries that it depends on. Finding a library is not as easy as finding a program using aptitude.

I downloaded the traceroute deb and displayed the contents using the command above. It provides a library called libsupp.a. If I was building an application that depends on libsupp.a, I wouldn’t be able to easily find it using aptitude. apt-file would show that it’s provided by traceroute.


dcolon@gold:~$ aptitude search libsupp.a
dcolon@gold:~$
dcolon@gold:~$ apt-file search libsupp.a
traceroute: /usr/lib/libsupp.a
dcolon@gold:~$