You can check which files were accessed by a program using strace
:
-e trace=file
Trace all system calls which take a file name as an
argument. You can think of this as an abbreviation
for -e trace=open,stat,chmod,unlink,... which is
useful to seeing what files the process is
referencing. Furthermore, using the abbreviation
will ensure that you don't accidentally forget to
include a call like lstat in the list. Betchya
woulda forgot that one.
So, something like:
$ strace -fe trace=file -o log /bin/bash -c ''
$ awk -F\" '!a[$2]++&&/\//{print $2}' log | xargs dpkg -S 2>/dev/null | awk -F: '!a[$1]++{print $1}'
bash
libtinfo5
libc6
Be warned, though: this output is not particularly useful one way or the other:
- It doesn't tell you which packages aren't used by a command, because the use could be by some way other than accessing a file (or maybe it accessed a file which was created by a package but not recorded in
dpkg
's database).
- It doesn't tell you which packages could have not been used by a package. For example, if I ran an interactive bash session, the number of packages is a lot higher, mostly because the completion scripts provided by those are also being counted. The list even includes GRUB! And GRUB clearly isn't needed by bash.
What you should do is start with ubuntu-minimal
and install only those things needed for the program to run over and above that (you'll know which ones are needed when the program dies of mysterious errors).