LDD
ldd command --> ldd (List Dynamic Dependencies)
ldd shows all libraries that it would need to load when starting the application or loading a shared library. readelf -d shows only direct dependencies of the binary.
How use ldd ?
ldd path_for_your_app_or_lib_which_ you_want_check
Examples
$ ldd /usr/bin/chacl
linux-vdso.so.1 (0x00007ffef49e0000) libacl.so.1 => /lib64/libacl.so.1 (0x00007f022ccf3000) libc.so.6 => /lib64/libc.so.6 (0x00007f022c93f000) libattr.so.1 => /lib64/libattr.so.1 (0x00007f022c73b000) /lib64/ld-linux-x86-64.so.2 (0x00007f022cefc000)
$ readelf -d /usr/bin/chacl | grep NEEDED 0x0000000000000001 (NEEDED) Shared library: [libacl.so.1] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
Other Command Examples
$ objdump -p /usr/bin/chacl | grep NEEDED NEEDED libacl.so.1 NEEDED libc.so.6
$ LD_TRACE_LOADED_OBJECTS=1 /usr/bin/chacl
linux-vdso.so.1 (0x00007ffd92eef000) libacl.so.1 => /lib64/libacl.so.1 (0x00007f161c6a8000) libc.so.6 => /lib64/libc.so.6 (0x00007f161c2f4000) libattr.so.1 => /lib64/libattr.so.1 (0x00007f161c0f0000) /lib64/ld-linux-x86-64.so.2 (0x00007f161c8b1000)
$ lddtree /usr/bin/chacl chacl => /usr/bin/chacl (interpreter => /lib64/ld-linux-x86-64.so.2) libacl.so.1 => /lib64/libacl.so.1 libattr.so.1 => /lib64/libattr.so.1 libc.so.6 => /lib/libc.so.6 ld-linux.so.2 => /lib/ld-linux.so.2
lddtree show dependencies hierarchical,
you see significant dependencies ( libacl.so.1 , libc.so.6 ) and less significant dependencies ( libattr.so.1 , ld-linux.so.2 )
Maybe I can try explained hierarchical ?
chacl ├──> libacl.so.1 | ├──> libattr.so.1 | | └──> libc.so.6 | | └──> ld-linux.so.2 | └──> libc.so.6 | └──> ld-linux.so.2 └──> libc.so.6 └──> ld-linux.so.2
However exist more dependencies, which not have path, but lddtree not show their. ( dynamic , linux-vdso.so.1 , linux-gate.so.1 ) more in link --> http://www.trilithium.com/johan/2005/08/linux-gate/
$ perl ldd-recursive.pl /usr/bin/chacl /usr/bin/chacl
linux-vdso.so.1
/lib64/libacl.so.1
linux-vdso.so.1 /lib64/libattr.so.1 linux-vdso.so.1 /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2 linux-vdso.so.1 /lib64/ld-linux-x86-64.so.2 /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2 linux-vdso.so.1 /lib64/ld-linux-x86-64.so.2 /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2 linux-vdso.so.1 /lib64/libattr.so.1 linux-vdso.so.1 /lib64/libc.so.6 /lib64/ld-linux-x86-64.so.2 linux-vdso.so.1 /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
Titbit
Commands like readelf, objdump can show you shared library, but do you know how check where is this lib in your system ?
You can use for example command find, but exist better way ... For example I try find libacl.so.1
$ locate libacl.so.1 /lib64/libacl.so.1 /lib64/libacl.so.1.1.0
$ ldconfig -p | grep libacl.so.1
libacl.so.1 (libc6,x86-64) => /lib64/libacl.so.1
How you can check which package provide this path ?
$ rpm -qf /lib64/libacl.so.1 lib64acl1-2.2.51-1pclos2013
Wiki editing help --> https://www.mediawiki.org/wiki/Help:Formatting/pl