22

I've installed some things manually in the past and would like to weed out all related files. So, I need a way to automatically find all the files (in /usr, for example) that are not included in any of the packages currently installed on the Debian system. However, I would also need to filter out the files that are created during package installation (by dpkg post-install scripts and similar things).

1

2 Answers 2

26

Use the cruft-ng package:

cruft-ng is a program to look over the system for anything that shouldn't be there, but is; or for anything that should be there, but isn't.

1
  • 1
    Note that as of 2022-10-07, cruft was removed from testing and may disappear from Debian. Feb 25 at 2:55
5

You could try something like this:

dpkg -L --list-all-package-files | grep "^/usr" > dpkg-files.dat   **(don't know the dpkg option "--list-all-package-files", read mand dpkg)**
find /usr -type f -o -type l > all-usr-files.dat
sort dpkg-files.dat all-usr-files.dat | uniq -c | grep " 1 "

This way you will get all files that are in /usr but not any package file. As a first shot this could help you.

5
  • I can't find any way to get -L to list more than one package at a time, but you can get the same effect from grep -h "^/usr" /var/lib/dpkg/info/*.list > dpkg-files.dat
    – DerfK
    Feb 21, 2011 at 16:04
  • There is no --list-all-package-files option.
    – Karol
    Feb 21, 2011 at 16:07
  • @DerfK: You can get -l to list more than one package, for example like this: dpkg -L `aptitude search ~i -F "%p"`
    – Karol
    Feb 21, 2011 at 16:11
  • The problem with this approach is that there are more files or links in /usr than actually listed by dpkg. For example, /usr/bin/aptitude exists, probably created by some post-installation script, but it's not listed by dpkg. So, I guess what I want here is a list of files installed or created by installing any package (will change question).
    – Karol
    Feb 21, 2011 at 16:18
  • @Karol: Other sources of files could be diversions and alternatives. The output is in sentence form but you can see diversions with dpkg-divert --list as root (These are usually given a suffix). Alternatives are a bit harder, the file format in /var/lib/dpkg/alternatives/ is awkward and update-alternatives tells me just about everything BUT the name of the link. find /usr -lname '/etc/alternatives/*' is probably the easiest way to get these.
    – DerfK
    Feb 21, 2011 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .