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

Is there any command for that?

5 Answers 5

/sbin/ldconfig -p

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
  • Something wrong with this command, it doesn't show anything. $ dpkg -S $(/sbin/ldconfig -p | awk 'NR>1 { print $NF }') 2>/dev/null | sed 's/\: .*$//' | sort -u
    – Raymond
    Jan 19, 2022 at 20:01

I'm not sure there's a guaranteed way to know from a package name that a package is a "library" (if that's even a solid definition in itself) but you can find installed packages that start and end with lib fairly easily:

dpkg -l | awk '($1 == "ii") && ($2 ~ /^lib|lib$/) { print $2 }'

Some packages contain "lib" that aren't libraries. You'll probably need to exclude librarian and libreoffice from those:

dpkg -l | awk '($1 == "ii") && ($2 ~ /^lib|lib$/) && ($2 !~ /^(libreoffice|librarian)/) { print $2 }'

This is still going to miss out a dearth of python-... libraries.


And aptitude came to the rescue:

aptitude search '?and(?section(libs), ~i)'

It reads: looks for packages that contains libs in their ?section and that are installed (~i).

You can use this to look for just all libraries in your repository:

aptitude search '?section(libs)'

This method obviously need of aptitude.

  • Note, this will work if the packages comply with Debian policies. If a library isn't in the library section, then it will not be included, even if it's a library.
    – Braiam
    Mar 14, 2014 at 12:47

You can use the following command for finding all installed packages in Ubuntu:

apt list --installed

You can search for a specific package using:

apt list --installed <package_name>

In case the above commands are not be permitted to be run by the user, then add sudo in front of them.

pkg-config --list-all
pkg-config --list-all | grep <package>
  • 2
    pkg-config is a computer program that defines and supports a unified interface for querying installed libraries for the purpose of compiling software that depends on them. It will not give you a complete list of installed packages. Aug 24, 2023 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .