Display shared libraries used by executables in linux

0 votes
So I want to know how to list all the libraries associated with executables on my system. Then I'd like to rank them according to the libraries which are used most with their corresponding binaries. How do I do this?
Jul 3, 2019 in Linux Administration by Atul
• 10,240 points
1,438 views

1 answer to this question.

0 votes

In order to do this, you need to:

  1. Use ldd to list shared libraries for each executable
  2. Clean the output
  3. Sort, compute counts and sort by count

Now, to do this for all binaries in the /bin directory:

find /bin -type f -perm /a+x -exec ldd {} \; \
| grep so \
| sed -e '/^[^\t]/ d' \
| sed -e 's/\t//' \
| sed -e 's/.*=..//' \
| sed -e 's/ (0.*)//' \
| sort \
| uniq -c \
| sort -n

If you want to search all the directories just use '/' instead of '/bin':

This is the output sample for the bin directory:

  1 /lib64/libexpat.so.0
  1 /lib64/libgcc_s.so.1
  1 /lib64/libnsl.so.1
  1 /lib64/libpcre.so.0
  1 /lib64/libproc-3.2.7.so
  1 /usr/lib64/libbeecrypt.so.6
  1 /usr/lib64/libbz2.so.1
  1 /usr/lib64/libelf.so.1
  1 /usr/lib64/libpopt.so.0
  1 /usr/lib64/librpm-4.4.so
  1 /usr/lib64/librpmdb-4.4.so
  1 /usr/lib64/librpmio-4.4.so
  1 /usr/lib64/libsqlite3.so.0
  1 /usr/lib64/libstdc++.so.6
  1 /usr/lib64/libz.so.1
  2 /lib64/libasound.so.2
  2 /lib64/libblkid.so.1
  2 /lib64/libdevmapper.so.1.02
  2 /lib64/libpam_misc.so.0
..... and so on
answered Jul 3, 2019 by ajs3033
• 7,300 points

Related Questions In Linux Administration

0 votes
1 answer

How to display available interfaces in Linux system?

Hi@akhtar, You can use tcpdump command in your ...READ MORE

answered Oct 4, 2020 in Linux Administration by MD
• 95,460 points
1,231 views
0 votes
1 answer

How to display captured packets in HEX and ASCII in Linux?

Hi@akhtar, To display the packet value you can ...READ MORE

answered Oct 4, 2020 in Linux Administration by MD
• 95,460 points
32,441 views
0 votes
0 answers

Linux command to display date in unix format

What command can I use in Linux ...READ MORE

Apr 13, 2022 in Linux Administration by Aditya
• 7,680 points
517 views
0 votes
0 answers

How to create user in linux by providing uid and gid options?

I have 2 linux machines. On one ...READ MORE

Apr 20, 2022 in Linux Administration by Edureka
• 13,690 points
816 views
0 votes
1 answer
+1 vote
2 answers

Execute Pig Script from Grunt Shell

From your current directory run  pig -x local Then ...READ MORE

answered Oct 25, 2018 in Big Data Hadoop by Kunal
6,234 views
0 votes
1 answer

How to stop messages from being displayed on spark console?

In your log4j.properties file you need to ...READ MORE

answered Apr 24, 2018 in Apache Spark by kurt_cobain
• 9,350 points
5,560 views
0 votes
1 answer

How to get Spark dataset metadata?

There are a bunch of functions that ...READ MORE

answered Apr 26, 2018 in Apache Spark by kurt_cobain
• 9,350 points
4,895 views
0 votes
1 answer

Setting environment variables in linux

You need to add more information about ...READ MORE

answered May 13, 2019 in Linux Administration by ajs3033
• 7,300 points
1,290 views
0 votes
1 answer

Linux: Using grep to display filenames

You need t use -l flag with ...READ MORE

answered May 24, 2019 in Linux Administration by ajs3033
• 7,300 points
791 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP