How to check what libraries are used by a program or process on Linux

Last updated on November 28, 2020 by Dan Nanni

Question: I would like to know which shared libraries are loaded at run-time when I invoke a particular executable. Is there any way to identify shared library dependencies of a program executable or a running process on Linux?

You can use the following methods to identiy which shared librariies a given program executable (e.g., /path/to/program) or a given running process (e.g., PID 1149) depends on.

Check Shared Library Dependencies of a Program Executable

To find out what libraries a particular executable depends on, you can use ldd command. This command invokes dynamic linker to find out library dependencies of an executable.

$ ldd /path/to/program

Note that it is not recommended to run ldd with any untrusted third-party executable because some versions of ldd may directly invoke the executable to identify its library dependencies, which can be security risk.

Instead, a safer way to show library dependencies of an unknown application binary is to use the following command.

$ objdump -p /path/to/program | grep NEEDED

Check Shared Library Dependencies of a Running Process

If you want to find out what shared libraries are loaded by a running process, you can use pldd command, which shows all shared objects loaded into a process at run-time.

$ sudo pldd <PID>

Note that you need root privilege to run pldd command.

Alternatively, a command line utility called pmap, which reports memory map of a process, can also show shared library dependencies of a running process.

$ sudo pmap <PID>

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean