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).
Asked
Active
Viewed 4,820 times
2 Answers
4
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.
rems
- 2,240
- 13
- 11
-
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
-
-
@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