Friday, 6 February 2015

Find out which libraries being used by a program in linux

To find out the libraries being used by a software, use ldd. ldd will tell you what libraries are loaded by a particular piece of software. For example:

[psj@localhost ~]$ ldd /usr/bin/python
    linux-gate.so.1 =>  (0x00221000)
    libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00222000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00ca4000)
    libdl.so.2 => /lib/libdl.so.2 (0x00cc1000)
    libutil.so.1 => /lib/libutil.so.1 (0x0723a000)
    libm.so.6 => /lib/libm.so.6 (0x00cd3000)
    libc.so.6 => /lib/libc.so.6 (0x00b0b000)
    /lib/ld-linux.so.2 (0x00ae9000)

To list libraries for the programs under execution, lsof is your best friend.

[psj@localhost ~]$ lsof -n -P +c 0 |grep udev
gnome-settings- 2227            psj  mem       REG      253,0    60160      69022 /lib/libudev.so.0.5.1
gnome-settings- 2227            psj  mem       REG      253,0    27456      69023 /usr/lib/libgudev-1.0.so.0.0.1
gnome-panel     2246            psj  mem       REG      253,0    60160      69022 /lib/libudev.so.0.5.1


Thanks to a great tip from Johannes B. Ullrich at SANS, ISC.

More details are available here - https://isc.sans.edu/forums/diary/What+is+using+this+library/19275/

No comments:

Post a Comment