How to check which binaries depend on certain files in /lib

binarycommandlibraries

I know that if I do the command ldd <name> on a binary file in /bin or /sbin I can see which libraries it uses. How do I do the reverse? I.e. do a command on a file in /lib and see what binaries are using it?

Best Answer

This isn't quite what you're asking for, but it will allow you to find the list of binaries using a given library. binstats generates a report on the binaries and libraries in your system, primarily to find out which binaries are missing libraries, and which libraries are no longer used at all.

In debug mode, it leaves its temporary files behind, and one of them lists all the binaries on the path (or in the folders you specify, using the -b option), with all the libraries they use. Once you have this file, you can search for the library you're interested in to determine what uses it...

So basically:

binstats -d
awk '/^\// { binary=$1 }; /libtinfo.so.5/ { print binary }' etempb.00

will list all the binaries using libtinfo.so.5. (The filename may not be etempb.00, but hopefully you get the idea...)

This will miss binaries stored in directories not on the path, e.g. in /usr/libexec, or in /sbin and /usr/sbin if you're not running as root, but you can add the relevant folders to the -b option.

Related Question