Using ldd to find shared dependencies

Published on .

Yesterday I discovered a cool program called ldd that ships with the GNU C library. ldd prints the shared libraries used by a program.

Running ldd /usr/bin/which, for example, returns: (0x00007ffe007cb000) => /lib64/ (0x00007f58600ed000) => /lib64/ (0x00007f58600e6000) => /lib64/ (0x00007f585ff1d000) => /lib64/ (0x00007f585fe8b000) => /lib64/ (0x00007f585fe84000)
/lib64/ (0x00007f5860162000) => /lib64/ (0x00007f585fe62000)

I found this helpful when setting up a chroot environment — it’s a quick way to find out which libraries need to be copied over.