Ubuntu – How to get a list of files on the computer that are not “owned” by any package

aptdeb

I'm contemplating writing a script that does this:

  • Goes through each file in /usr/lib
  • Does a dpkg -s search on each file.
  • Reports a list of "orphan" files not belonging to any .deb package.

The idea is that over time, I've installed a lot of make install software and I'd like to get a list of leftover files from manually installed software I've since deleted.

Best Answer

find /usr/lib -type f -exec dpkg -S {} + 2>&1 >/dev/null | sed -r 's/^[^/]+//'

I'll warn you now: it's slow.

Related Question