Linux list all libs

Command to list the directories in which to look for shared libraries?

I’ve read which equivalent for shared libraries and Where do executables look for shared objects at runtime, but is there a command to list all the directories in which the shared libraries will be searched? Something like a command that auto-computes all the list explained in the second question.

4 Answers 4

long: The related environment variables are system- and configuration-dependent. For a given system/configuration, you could write a script which does this.

Where do executables look for shared objects at runtime gives some insight, but is incomplete. It mentions OSX and Solaris, but focuses on Linux, pointing to two resources:

  • Program Library HOWTO: 3. Shared Libraries (which mentions LD_LIBRARY_PATH without mentioning the less-often LD_LIBRARY_PATH_64 , and also gives a one-line mention of rpath).
  • ld.so, ld-linux.so* — dynamic linker/loader, which again mentions some of the environment variables and rpath.

You would also find these useful:

ldconfig creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf , and in the trusted directories, /lib and /usr/lib (on some 64-bit architectures such as x86-64, lib and /usr/lib are the trusted directories for 32-bit libraries, while /lib64 and /usr/lib64 are used for 64-bit libraries).

In particular, » sudo ldconfig -v «

-v , —verbose
Verbose mode. Print current version number, the name of each directory as it is scanned, and any links that are created. Overrides quiet mode.

which is close to what was asked, but gives lots of extraneous information. (And it is largely Linux-specific, though BSDs use it — but different, see manual page). If you make some assumptions about its output format, you could get directories from this using

sudo ldconfig -v 2>/dev/null | grep ':$' |sed -e 's/://' 

which gives (on one system)

/usr/local/lib /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /lib /usr/lib 

To recap: there is no command, but you can make a script, which is system-dependent.

Источник

Читайте также:  Arch linux wayland install

How do I get a list of shared library filenames under Linux?

Is there a GNU Linux built-in for getting a list of the filenames of shared libraries? I have considered parsing the output of ldconfig -p . However, I’m not sure about consistency in output from system to system. I am already aware that I could use find but given that the linker / loader has a cache of libraries and locations, it seems more efficient to use it in some way. Additionally, the paths that the linker / loader searches are the only ones I’m concerned with—i.e libraries that have been processed by ldconfig .

1 Answer 1

If you want to catch them all, there is no other choice but to do full filesystem traversals. ldconfig knows only about the libraries in the standard paths and the extra paths it is configured to look in (usually defined in /etc/ld.so.conf* ). The usual suspect places where other libraries can be found are $HOME and /opt , though there is no limit, especially when people build applications themselves.

If you don’t trust the output of ldconfig -p , you can parse its cache directly. It’s binary, but using strings removes all the garbage (5 so /lib/ matches):

On my system, they both give the same results, which I verified with this quicky:

a=$(ldconfig -p | awk -F'> ' '' | sort); # get them to the same format b=$(strings -n5 /etc/ld.so.cache | sort -u); echo -e "$a\n$b\n$b" | sort | uniq -u 

Which checked if any library on the ldconfig -p list was not mentioned in the cache. Nothing was returned.

Источник

How to get the list of installed library packages only?

I want to get the list of installed library packages only from terminal. Is there any command for that?

5 Answers 5

The -v option will show the libraries version.

267 libs found in cache `/etc/ld.so.cache' libz.so.1 (libc6) => /usr/lib/libz.so.1 libz.so (libc6) => /usr/lib/libz.so libxslt.so.1 (libc6) => /usr/lib/libxslt.so.1 libxml2.so.2 (libc6) => /usr/lib/libxml2.so.2 libxcb.so.1 (libc6) => /usr/lib/libxcb.so.1 libxcb-xlib.so.0 (libc6) => /usr/lib/libxcb-xlib.so.0 libwrap.so.0 (libc6) => /lib/libwrap.so.0 libvolume_id.so.0 (libc6) => /lib/libvolume_id.so.0 libuuid.so.1 (libc6) => /lib/libuuid.so.1 libutil.so.1 (libc6, hwcap: 0x8008000000008000, OS ABI: Linux 2.6.8) => /lib/tls/i686/cmov/libutil.so.1 libutil.so.1 (libc6, OS ABI: Linux 2.6.8) => /lib/libutil.so.1 libutil.so (libc6, OS ABI: Linux 2.6.8) => /usr/lib/libutil.so libusb-0.1.so.4 (libc6) => /lib/libusb-0.1.so.4 libusb-0.1.so.4 (libc6) => /usr/lib/libusb-0.1.so.4 libulockmgr.so.1 (libc6) => /lib/libulockmgr.so.1 libt1x.so.5 (libc6) => /usr/lib/libt1x.so.5 libt1.so.5 (libc6) => /usr/lib/libt1.so.5 libtiff.so.4 (libc6) => /usr/lib/libtiff.so.4 libticw.so.5 (libc6) => /lib/libticw.so.5 

If you want to turn that list into a list of packages, you can do something like this:

dpkg -S $(/sbin/ldconfig -p | awk 'NR>1 < print $NF >') 

And you can further massage that to cut out errors, unneeded components and duplicates:

$ dpkg -S $(/sbin/ldconfig -p | awk 'NR>1 < print $NF >') 2>/dev/null | sed 's/\: .*$//' | sort -u akregator ark binutils calligra-libs comerr-dev compiz-core dolphin e2fslibs:amd64 freeglut3:amd64 gettext . 

Источник

Читайте также:  Linux dhcp server ubuntu

How to List Shared Libraries Used by Executables in Linux

Under a Linux operating system environment, the binary executables associated with the applications/programs you wish to run are directly linked with shared libraries loaded at runtime.

As a curious and evolving Linux user, you will be tempted to get an idea about these shared libraries involved/linked with the binary executables you are running during a normal program startup.

This article will walk us through several approaches to find out all shared libraries used by executables in Linux.

Brief Overview on Linux Libraries

A programmer or a user familiar with the programming world will define a library as pre-compiled code pieces/segments put together in an organized manner/format. The pre-compiled nature/attribute of a library makes it flexibly and easily reusable among different programs.

Under the Linux operating system architecture, we can categorize libraries as either static (static libraries) or shared (shared libraries).

Static libraries are statically bound to a specific program and are only accessible during the program’s compilation time. Shared libraries become active once a program is launched and will reside in memory during the program’s runtime duration.

How to Find a Program’s Shared Libraries in Linux

Before determining the shared libraries associated with your targeted program, you first need to know where the executable associated with your program is residing. In Linux, the location for your programs’ executables is usually inside the /usr/bin directory.

List All Linux Executable Programs

The column on the far-right lists the names of your programs’ executables.

Find Shared Libraries of Linux Program Using the ldd Command

The ldd command exists as a straightforward shell script that points to a program’s shared libraries. As per the screen capture above, let us for instance attempt to output the shared libraries associated with the anydesk application.

We could determine Anydesk’s executable’s location with the command:

To determine its shared libraries via the ldd command, we will execute:

Find Shared Libraries of Linux Program

As you can see, we have a list of numerous libraries associated with anydesk application. Please note that the ldd command tends to execute queried programs to retrieve shared libraries info. Therefore, only associate the command with trusted executables.

Find Program Shared Libraries Using objdump and grep Commands

The objdump command being part of the GNU Binutils package will focus on displaying the object files information whereas the grep command will list the program’s associated shared libraries.

Let us see what these commands will yield for a program like whois used for domain names info.

Читайте также:  Running linux usb stick

Find Program Binary Location

Next, find out the shared libraries of program.

$ objdump -p /usr/bin/whois | grep 'NEEDED'

Find Linux Program Shared Libraries

As you can see, the whois domain lookup program executable is associated with two shared libraries.

Alternatively, you can also use the readelf command to retrieve shared information for the zip program’s executable.

$ whereis zip $ readelf --dynamic /usr/bin/zip | grep NEEDED

Find Zip Program Shared Libraries

As per the output, the zip program executable is associated with two shared libraries.

Find Shared Libraries Using Awk Command

This option is ideal for a program that is already running. We first need to get it’s PID (Process ID). For instance, let’s say we have the Flameshot screen capture utility running.

To get its PID, we will run:

$ pgrep flameshot 45261 

Our /proc//maps file will be transformed to /proc/45261/maps. We can now combine this file with the awk command to retrieve Flameshot executable shared libraries as demonstrated below.

$ awk '$NF!~/\.so/  !a[$0]++' /proc/45261/maps

Find Shared Libraries Using Awk Command

We are now well-acquainted in listing all shared libraries associated with program executables in Linux.

Источник

How to List All Libraries and Files in a Package on Linux

yum is a good tool to resolve dependencies of a package, but it cannot list all the libraries and files with definitive path in a package. We should use a more advance utility repoquery to retrieve the information. Since repoquery is included in yum-utils package which is not a default package for most Linux distros, so we should install it first.
[root@test ~]# yum -y install yum-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nsysu.edu.tw
* extras: mirrors.skyshe.cn
* updates: ftp.nsysu.edu.tw
Setting up Install Process
Resolving Dependencies
—> Running transaction check
—> Package yum-utils.noarch 0:1.1.30-17.el6_5 will be installed
—> Finished Dependency Resolution

Total download size: 102 k
Installed size: 302 k
Downloading Packages:
yum-utils-1.1.30-17.el6_5.noarch.rpm | 102 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : yum-utils-1.1.30-17.el6_5.noarch 1/1
Verifying : yum-utils-1.1.30-17.el6_5.noarch 1/1

Installed:
yum-utils.noarch 0:1.1.30-17.el6_5

Complete!
Now, let’s see an example of listing all libraries and files.
[root@primary01 ~]# repoquery -l mysql-libs.x86_64
/etc/ld.so.conf.d/mysql-x86_64.conf
/etc/my.cnf
/usr/lib64/mysql
/usr/lib64/mysql/libmysqlclient.so.16
/usr/lib64/mysql/libmysqlclient.so.16.0.0
/usr/lib64/mysql/libmysqlclient_r.so.16
/usr/lib64/mysql/libmysqlclient_r.so.16.0.0
/usr/share/doc/mysql-libs-5.1.73
/usr/share/doc/mysql-libs-5.1.73/COPYING
/usr/share/doc/mysql-libs-5.1.73/README.mysql-license
/usr/share/mysql
/usr/share/mysql/charsets
/usr/share/mysql/charsets/Index.xml
/usr/share/mysql/charsets/README
/usr/share/mysql/charsets/armscii8.xml
/usr/share/mysql/charsets/ascii.xml
/usr/share/mysql/charsets/cp1250.xml
/usr/share/mysql/charsets/cp1251.xml
/usr/share/mysql/charsets/cp1256.xml
/usr/share/mysql/charsets/cp1257.xml
/usr/share/mysql/charsets/cp850.xml
/usr/share/mysql/charsets/cp852.xml
/usr/share/mysql/charsets/cp866.xml
/usr/share/mysql/charsets/dec8.xml
/usr/share/mysql/charsets/geostd8.xml
/usr/share/mysql/charsets/greek.xml
/usr/share/mysql/charsets/hebrew.xml
/usr/share/mysql/charsets/hp8.xml
/usr/share/mysql/charsets/keybcs2.xml
/usr/share/mysql/charsets/koi8r.xml
/usr/share/mysql/charsets/koi8u.xml
/usr/share/mysql/charsets/latin1.xml
/usr/share/mysql/charsets/latin2.xml
/usr/share/mysql/charsets/latin5.xml
/usr/share/mysql/charsets/latin7.xml
/usr/share/mysql/charsets/macce.xml
/usr/share/mysql/charsets/macroman.xml
/usr/share/mysql/charsets/swe7.xml
/usr/share/mysql/czech
/usr/share/mysql/czech/errmsg.sys
/usr/share/mysql/danish
/usr/share/mysql/danish/errmsg.sys
/usr/share/mysql/dutch
/usr/share/mysql/dutch/errmsg.sys
/usr/share/mysql/english
/usr/share/mysql/english/errmsg.sys
/usr/share/mysql/estonian
/usr/share/mysql/estonian/errmsg.sys
/usr/share/mysql/french
/usr/share/mysql/french/errmsg.sys
/usr/share/mysql/german
/usr/share/mysql/german/errmsg.sys
/usr/share/mysql/greek
/usr/share/mysql/greek/errmsg.sys
/usr/share/mysql/hungarian
/usr/share/mysql/hungarian/errmsg.sys
/usr/share/mysql/italian
/usr/share/mysql/italian/errmsg.sys
/usr/share/mysql/japanese
/usr/share/mysql/japanese/errmsg.sys
/usr/share/mysql/korean
/usr/share/mysql/korean/errmsg.sys
/usr/share/mysql/norwegian
/usr/share/mysql/norwegian-ny
/usr/share/mysql/norwegian-ny/errmsg.sys
/usr/share/mysql/norwegian/errmsg.sys
/usr/share/mysql/polish
/usr/share/mysql/polish/errmsg.sys
/usr/share/mysql/portuguese
/usr/share/mysql/portuguese/errmsg.sys
/usr/share/mysql/romanian
/usr/share/mysql/romanian/errmsg.sys
/usr/share/mysql/russian
/usr/share/mysql/russian/errmsg.sys
/usr/share/mysql/serbian
/usr/share/mysql/serbian/errmsg.sys
/usr/share/mysql/slovak
/usr/share/mysql/slovak/errmsg.sys
/usr/share/mysql/spanish
/usr/share/mysql/spanish/errmsg.sys
/usr/share/mysql/swedish
/usr/share/mysql/swedish/errmsg.sys
/usr/share/mysql/ukrainian
/usr/share/mysql/ukrainian/errmsg.sys

Источник

Оцените статью
Adblock
detector