To check your libc (glibc) version type “ls -l /lib/libc.” and hit TAB. This should expand the line into the name of your libc library file, e.g. something like /lib/libc.so.6
Umm… no, the .6 does not mean that your glibc version is 6, unfortunately it is a little more complicated than that 🙂 … but not too much!
Now that you know the name of the file run it as an executable, i.e. just type /lib/libc.so.6 in the console (or whatever your lib is named). It should dump lot’s of info that looks like this:
GNU C Library stable release version 2.8, by Roland McGrath et al.
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.3.0 20080428 (Red Hat 4.3.0-8).
Compiled on a Linux >>2.6.18-92.1.6.el5<< system on 2008-07-16.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>
So as you can see your glibc (libc.so) version is 2.8.
Another approach would be to get it programatically as explained in this thread
A simpler way is to use the ldd command to check the version.
#ldd –version
If you use dpkg, this will display a one-line summary of the libc *package* that you’re using:
dpkg-query -l libc6
— tip: this usage allows several patterns and globbing such asdpkg-query -l '*libc[^a-z]' '*libc'
Also with dpkg-query, a long report with more details:
dpkg-query -s libc6
And then
dpkg-query -W -f=... ...
allows some custom formatting of desired details, although, the format codes are a bit tough to figure out, not well documented in the manual page. For the details, refer to the source.If you (also) use aptitude, this will display a long report similar to (maybe the same as)
dpkg -s
(but as opposed to dpkg-query it needs a direct match for a package name, no globbing):aptitude show libc6
And then, to get back to the original article, sometimes there is no file matching /lib/libc.* (depending on the distro in use). But the proper use case of ldd helps here: given any dynamic executable that links to libc.so.6 (and as good as all dynamic executables do), specifying that executable’s name to ldd will cause ldd to display all the pathes to which the references *actually* will be resolved. Then, you can use that path to do as the article advises: execute the library file itself so that its stub displays its version information.
Here’s an example command to display both the pathname (to stderr) and the version information (to stdout):
$(ldd $(which bash) | grep -E "libc\." | sed -re 's/^ *[^ ]+ *=> *([^ ]*)( +.*)?$/\1/' | tee /dev/stderr )
(Notably, the package details as well as the version information from the libc executable itself also indicate whether a derivative libc is in use; for instance, eglibc has a version number alike to the original glibc, but seems to be independently maintained nowadays.)