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 in Linux Administration by Atul
• 10,240 points
36 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 by ajs3033
• 7,280 points

Related Questions In Linux Administration

–1 vote
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3 in Linux Administration by Omkar
• 67,660 points
109 views
0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Jan 31 in Linux Administration by Omkar
• 67,660 points
72 views
0 votes
1 answer

Finding pat of afile in linux

You can use readlink command: readlink -f filename.txt for ...READ MORE

answered Mar 15 in Linux Administration by DareDev
• 6,810 points
26 views
0 votes
1 answer

generating a list of files with their absolute path in Linux

If you find an absolute path to start with, ...READ MORE

answered May 16 in Linux Administration by Upasana
• 8,530 points
38 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
935 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,260 points
1,306 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,260 points
453 views
0 votes
1 answer

Setting environment variables in linux

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

answered May 13 in Linux Administration by ajs3033
• 7,280 points
27 views
0 votes
1 answer

Linux: Using grep to display filenames

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

answered May 24 in Linux Administration by ajs3033
• 7,280 points
34 views