Sunday, March 11, 2018

Oracle Linux - check shared library version

As we have seen in a previous post, you can quickly see which shared library files are used by an executable under Oracle Linux by a specific executable. In our example we found that libidn.so.11 and libc.so.6 are both used by ping under Oracle Linux. We extracted that information by using the elfread command. Even though this is providing some information it is not telling you the exact version that is used at present. In case you do need to know which exact version is used you will have to dig a bit deeper into the system.

In a previous example we used the below command on Oracle Linux to find out the shared library files for the ping command.

[root@localhost tmp]# readelf -d /bin/ping | grep 'NEEDED'
 0x0000000000000001 (NEEDED)             Shared library: [libidn.so.11]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
[root@localhost tmp]# 

If you like to have a bit more information on the version that is used (for example libidn.so.1) you can use ldconfig. 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).

This means that ldconfig can provide a lot of information than we might want. In the below example (only first couple of lines) we do a verbose output of ldconfig.

[root@localhost tmp]# ldconfig -v
ldconfig: /etc/ld.so.conf.d/kernel-4.1.12-61.1.28.el6uek.x86_64.conf:6: duplicate hwcap 1 nosegneg
/lib:
/lib64:
 libattr.so.1 -> libattr.so.1.1.0
 libplc4.so -> libplc4.so
 libdevmapper.so.1.02 -> libdevmapper.so.1.02
 libdevmapper-event-lvm2.so.2.02 -> libdevmapper-event-lvm2.so.2.02
 libplds4.so -> libplds4.so
 libnss_hesiod.so.2 -> libnss_hesiod-2.12.so
 libfreeblpriv3.so -> libfreeblpriv3.so
 libselinux.so.1 -> libselinux.so.1
 libz.so.1 -> libz.so.1.2.3
 libdevmapper-event.so.1.02 -> libdevmapper-event.so.1.02
 libip6tc.so.0 -> libip6tc.so.0.0.0-1.4.7
 libmount.so.1 -> libmount.so.1.1.0
 libgpg-error.so.0 -> libgpg-error.so.0.5.0
 liblvm2app.so.2.2 -> liblvm2app.so.2.2

Now, if we want to have some information on libidn.so.11 we can do so by adding grep to the command via a pipe to only have the information we want.

[root@localhost tmp]# ldconfig -v | grep libidn.so.11
ldconfig: /etc/ld.so.conf.d/kernel-4.1.12-61.1.28.el6uek.x86_64.conf:6: duplicate hwcap 1 nosegneg
 libidn.so.11 -> libidn.so.11.6.1
[root@localhost tmp]# 

As you can see from the above output, libidn.so.11 is linked to libidn.so.11.6.1 which is the actual version used (via linking) by the ping executable we used as an example.

Post a Comment