Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to view dependent libraries used by programs or processes on Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to view the dependent library used by programs or processes on Linux, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Sometimes we encounter such a scenario: a Linux computer needs to execute a program that has not been installed yet. If we have an installation package for this program, we can install it directly or install it on the Internet, but if we do not have the installation package of this program and the computer cannot connect to the Internet, we can copy the program and dependent library files from another computer that has installed the program (ensure the same platform and system). Therefore, you need to know the dependent libraries used by the program. Here's how to view dependent libraries used by programs or processes on Linux.

View the shared library dependencies of executable programs

$ldd / path/to/program

$ldd / bin/ls linux-vdso.so.1 = > (0x00007fff73b06000) libselinux.so.1 = > / lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f0ba2672000) libacl.so.1 = > / lib/x86_64-linux-gnu/libacl.so.1 (0x00007f0ba246a000) libc.so.6 = > / lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ba20a3000) libpcre.so.3 = > / lib / x86_64-linux-gnu/libpcre.so.3 (0x00007f0ba1e65000) libdl.so.2 > / lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0ba1c61000) / lib64/ld-linux-x86-64.so.2 (0x00007f0ba28b9000) libattr.so.1 = > / lib/x86_64-linux-gnu/libattr.so.1 (0x00007f0ba1a5b000)

Be careful! It is not recommended to run ldd for any untrusted third-party executable, because some versions of ldd may call the executable directly to identify its library file dependencies, which may not be safe.

Instead, use a more secure way to display the library file dependencies of an unknown application binary, using the following command: $objdump-p / path/to/program | grep NEEDED

$objdump-p / bin/ls | grep NEEDED NEEDED libselinux.so.1 NEEDED libacl.so.1 NEEDED libc.so.6 to view the shared library dependencies of the running process

If you want to find out which shared libraries are loaded by a running process, you can use the pmap command, which reports the memory mapping of a process and also shows the library file dependencies of the running process: $sudo pmap

$pmap 52715271: vim / home/linjc/test/test/a.txt0000000000400000 2420K Rafael-vim.gnome000000000085d000 4K Rafael-vim.gnome000000000085e000 96K rw--- vim.gnome0000000000876000 60K rw--- [anon] 00000000023b7000 4276K rw--- [anon] 00007fba38e1f000 44K Rafael-libnss_files-2.19.so00007fba38e2a000 2044K-libnss_files-2.19.so00007fba39029000 4K Rafael-libnss_files-2 .19.so00007fba3902a000 4K rw--- libnss_files-2.19.so00007fba3902b000 44K Rakoto-libnss_nis-2.19.so00007fba39036000 2044K-libnss_nis-2.19.so00007fba39235000 4K Rakoto-libnss_nis-2.19.so00007fba39236000 4K rw--- libnss_nis-2.19.so00007fba39237000 92K Rafael-libnsl-2.19.so00007fba3924e000 2044K-libnsl-2.19.so00007fba3944d000 4K r- -libnsl-2.19.so00007fba3944e000 4K rw--- libnsl-2.19.so00007fba3944f000 8K rw--- [anon] 00007fba39451000 36K rMurray-libnss_compat-2.19.so00007fba3945a000 2044K-libnss_compat-2.19.so00007fba39659000 4K Rafael-libnss_compat-2.19.so00007fba3965a000 4K rw--- libnss_compat-2.19.so00007fba3965b000 4K-[anon] 00007fba3965c000 8192 K rw -[anon] 00007fba39e5c000 5748K rmurmuri-locale-archive. The above is how to view the dependent libraries used by programs or processes on Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report