Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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).

share|improve this question
1  
See also this question: unix.stackexchange.com/questions/18038/… –  Taha Jahangir Jan 4 '12 at 17:07

2 Answers 2

up vote 12 down vote accepted

Use the cruft package.

share|improve this answer

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.

share|improve this answer
    
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 '11 at 16:04
    
There is no --list-all-package-files option. –  Karol Feb 21 '11 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 '11 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 '11 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 '11 at 16:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.