Ubuntu – How to get the list of installed library packages only

command line

I want to get the list of installed library packages only from terminal.

Is there any command for that?

Best Answer

/sbin/ldconfig -p

The -v option will show the libraries version.

Result:

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
...