ldd /bin/bash | awk 'BEGIN{ORS=","}$1~/^\//{print $1}$3~/^\//{print $3}' | sed 's/,$/\n/'

List the libraries used by an application

For example, you need to make a copy of all the libraries that a certain application uses, with this command you can list and copy them.
Sample Output
/lib/libncurses.so.5,/lib/tls/i686/cmov/libdl.so.2,/lib/tls/i686/cmov/libc.so.6,/lib/ld-linux.so.2

3
By: cicatriz
2010-08-06 12:18:56

These Might Interest You

  • This function returns TRUE if the application supports tcp-wrapping or FALSE if not by reading the shared libraries used by this application. Show Sample Output


    1
    supportsWrap(){ ldd `which ${1}` | grep "libwrap" &>/dev/null && return 0 || return 1; }
    cicatriz · 2010-12-01 15:22:29 0
  • this command will install the packages which provides the libraries you need to link with, e.g. when you compile something needs opengl libraries: gcc -o testgl testgl.c -lGLEW -lGL -lGLU -lglut you can use `/usr/lib/libGLEW.so /usr/lib/libGL.so /usr/lib/libGLU.so /usr/lib/libglut.so'


    0
    yum whatprovides /usr/lib/libXX1.so /usr/lib/libXX2.so | grep fc | sed 's/^\(.*\)-[0-9.]*-.*$/\1/' | sort | uniq | xargs yum -y install
    laputa · 2011-03-07 04:51:35 0
  • this application monitors the apps you use most often and load them into memory with their libraries and other dependencies. So now, when you launch Firefox or Thunderbird or OpenOffice, the display is immediate as on Mac.


    -7
    sudo apt-get install preload
    danfernbanck · 2009-02-13 19:34:57 0
  • This is the best way I have found to search out an application when I am not sure the title. Grep is just to remove anything that does not contain the term in the title or short description (lots of things might include the search term in the description, such as libraries used by the application) Show Sample Output


    0
    aptitude search ~d "irc client"|grep -i "irc client"
    tomjrace · 2011-07-11 19:48:55 0
  • When working with jailed environments you need to copy all the shared libraries to your jail environment. This is done by running ldd on a binary which needs to run inside the jail. This command will use the output from ldd to automatically copy the shared libraries to a folder of your choice. Show Sample Output


    2
    ldd file | grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination
    rickard2 · 2012-02-11 17:50:10 0
  • This command is very helpful when we need to duplicate a test scenario and first we want to find out the installed libraries together with the version and release numbers and architecture. (look example) Command can be tuned by choosing just the names of libraries we are interested in. For example glibc and gcc. Show Sample Output


    1
    rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}\n'|egrep 'compat|glibc|gcc|libst|binu'|sort
    ovalerio · 2009-02-23 10:17:47 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: