Listing and Removing Broken Packages on Ubuntu/Debian

Listing

dpkg --list | grep ^rc

Removing

sudo dpkg --purge `dpkg --get-selections | awk '/deinstall/ {print $1}'`

Thanks to Frank Dietrich, who kindly posted this command on the Debian mailing list.

http://www.mail-archive.com/debian-user-german@lists.debian.org/msg178082.html

Note: if nothing is broken, the following appears::

Options marked with [*] produce lots of output - pipe it through »less« or »more«!