Finding Out What You’re Running

Finding Out What You’re Running

Brad B. asks:

“When I look for software online and they list requirements like
‘must have Python x.xx,’ how does one find out if their
distribution came with ‘Python x.xx’ or some other such library?
Is it a Find File thing, or do I need to go to the dreaded

Dee-Ann responds:

I’m such a geek. I like working at the console. Of course, you can
also open a terminal window in your GUI and not completely leave
the GUI if you’re not comforable when faced with only a black
screen with white letters. I’ve decided to cover this in EGGS
instead of MAN because there’s a number of ways to do this,
partially depending on what distribution you’re running.

If you’re running an RPM-based distribution, such as Red Hat,
Mandrake, or SuSE, you can get a package’s version number by using
the rpm command. I’ll use
Python as the example, since you mentioned it specifically. If you
have Python installed on your system, you can type:

rpm -q python

This gives me the results:


The last item in the version number, the -26, is probably related
to the distribution’s version of the Python package. This one
would be the 26th variant on Python 2.2.2. Don’t worry about this
issue. What matters is the 2.2.2.

If you’re running a DEB-based distribution, like Debian or
Knoppix, then you can find out what version of the package in
question is using the apt-cache utility. In this case, you’d type:

apt-cache show python

This gives me the following results when I type it in Knoppix:

Package: python
Status: install ok installed
Priority: standard
Section: interpreters
Installed-Size: 52
Maintainer: Matthias Klose 
Source: python2.2
Version: 2.2.2-6
Depends: python2.2 (>= 2.2.2-5)
Suggests: python-doc, python-tk
Conflicts: python2.1 (python2.1-base
((python-regrtest (ipcheck (pycmail (((

Notice the bolded pair of lines, there's the information you're
looking for. 

If you're not utilizing RPM or DEB, don't worry. There's a number of ways you can find out what version you're running. If you're running the version that came with your distribution, you can use the filesystem movement commands (ls for listing the contents of a directory, and cd for changing directories) to look through its packages on the CD-ROM, which likely have the version number in the name. For example:


Finally, you can usually ask a program itself what version it is. Just like you can find this information in a GUI tool by clicking Help | About, there are a number of ways to ask a command-line program. In the case of Python, our example, I type python and look what I get:

$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Oddly, if I type exit or
quit to get out, I'm told:

'Use Ctrl-D (i.e. EOF) to exit.'

So, I get out with Ctrl-D.
What if I want to know what version of Perl I'm running? Just
typing perl gets me into "the
program's expecting input" territory. I Ctrl-C out of there and look at the man page (typing man perl). No
information on how to get the version in there. So, I type perl -h, which is a commonly-used
format for getting help information (another is command -h). Now we're getting somewhere! I get
a long list of options. I cut these down to just what I want and
use a pipe to send the output of perl -h as input to grep, which is a program that will search for the
text I specify:

$ perl -h | grep version
  -v              print version, subversion (includes VERY IMPORTANT perl info)

Great! So, I can finally get the version information:

perl -v

This is perl, v5.8.0 built for i386-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2002, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using 'man perl' or 'perldoc perl'.  If you have access to the
Internet, point your browser at, the Perl Home Page.

Hope that helps!