Which Linux or UNIX Version Am I Running?

Wednesday, November 17, 2010

Jamie Adams


This may seem like a simple question but for a lot of system administrators who “inherit” systems or are unfamiliar with operating systems that have been forced upon them, it can be very confusing, especially if you're coming from a proprietary UNIX® operating system such as Solaris™ or HP-UX to a Linux®-based distribution.

For most of us old-school UNIX people, the reliable “uname” utility is what we are most familiar with. Execute it with the -a option and you get something like:

SunOS sungod 5.10 Generic_137138-09 i86pc i386 i86pc

Cryptic to most but for a seasoned Solaris administrator it means that the host “sungod” is running Solaris 10 on an x86 (non-SPARC) system and the current kernel patch level is 137138-09.

If you run the same command on a Linux system, you might see something like:

Linux greenlantern #1 SMP 2010-09-20 11:03:26 -0400 \ x86_64 x86_64 x86_64 GNU/Linux

At most, you can determine that the host “greenlantern” is in fact a Linux system running a default kernel version 2.26.47 and it is a 64-bit system because of the “x86_64” in the statement.

The “uname” utility was first introduced as part of the UNIX Programmer's Workbench (PWB) in 1973. Not only is “uname” a utility, it is a system call – uname() conforms to System Vr4 and POSIX.1-2001. It extracts information from the running kernel.

Linux distributions are built off of standard kernels but are packaged and bundled differently. Some distributions are Debian-based while others might be Red Hat-based. The collection of packages and how the packages were compiled and ultimately delivered are what make Linux distributions unique.

Most UNIX and Linux operating systems have some form of a release file detailing the operating system version and release information. This file, usually in the /etc directory, is a simple text file.

Some operating systems adhere to POSIX while others strive to be Linux Standard Based (LSB). Of course there are more standards and this fact reminds me of Andrew Tanenbaum's famous statement, “The nice thing about standards is that there are so many of them to choose from.”

For those systems which comply with LSB, you can use the lsb_release(8) utility. For example, running the lsb_release command on my openSUSE system reveals the following:

$ lsb_release -r -i -c -d
Distributor ID: SUSE LINUX
Description: openSUSE 11.1 (x86_64)
Release: 11.1
Codename: n/a

Much more informative than the “uname” utility. It should be noted that the utility just parses various configuration files such as those in /etc. Specifically, on SUSE systems it examines the following files:

$ ls -l /etc/SuSE-*
-rw-r--r-- 1 root root 24 Dec 3 2008 /etc/SuSE-brand
-rw-r--r-- 1 root root 38 Dec 4 2008 /etc/SuSE-release

Here is a list of some operating systems, related commands, and their release files which will help you determine the specific version and release of your operating system:

Operating System   |   Command or Configuration Files

AIX                                            uname -a

                                                 oslevel -g

Fedora                                      /etc/fedora-release

FreeBSD                                    uname -a

HP-UX                                        uname -a

OpenSUSE and Novell SUSE     /etc/SuSE-brand

Red Hat                                    /etc/redhat-release

Solaris                                      /etc/release

Ubuntu                                     /etc/lsb-release

Finally, many system administrators are confused when they apply all of the available updates to their system via their local software repositories but are still running the same minor revision.

For example, if you are running openSUSE 11.1 and you perform a “zypper update” to install available software updates, this will not bring your system up to openSUSE 11.2. To do this, you must specifically issue the distribution upgrade command. (zypper dist-upgrade).

This is because when you perform a normal update, it is only examining the repositories your current system has configured. For example, here is my list of repositories (zypper lr):

$ zypper lr
# | Alias                        | Name                        | Enabled | Refresh
1 | NVIDIA                     | NVIDIA                             | Yes | Yes
2 | NVIDIA-11.1             | NVIDIA-11.1                     | Yes | No
3 | Packman Repository| Packman Repository       | Yes | Yes
4 | adobe-linux-i386      | Adobe Systems Inc          | Yes | No
5 | google                      | Google - i386                  | Yes | No
6 | google-chrome         | google-chrome                | Yes | Yes
7 | google-testing          | Google Testing - i386      | Yes | No
8 | openSUSE 11.1-0     | openSUSE 11.1-0            | No  | No
9 | repo-debug              | openSUSE-11.1-Debug    | No  | Yes
10 | repo-non-oss         | openSUSE-11.1-Non-Oss | Yes | Yes
11 | repo-oss                | openSUSE-11.1-Oss         | Yes | Yes
12 | repo-source           | openSUSE-11.1-Source    | No  | Yes
13 | repo-update          | openSUSE-11.1-Update    | Yes | Yes

On the other hand, Red Hat distributions such as CentOS would be updated to the next minor revision (e.g., 5.4 to 5.5) because of the way the repositories are structured.

For system administrators maintaining patch levels and an accurate inventory of their systems, it is imperative they know how to determine the exact operating system version you are running.

Hopefully, this post has provided some guidance on clarifying how to find this important information.

Cross-posted from Security Blanket Technical Blog

Possibly Related Articles:
Operating Systems
Information Security
Unix Operating Systems Linux Administration
Post Rating I Like this!
Lee Mangold learn something new every day...I've never used lsb_release. Any idea which distros support lsb? (other than CentOS/RHEL which I just tried)
Jamie Adams Lee.. that is a good question. I use it in Novell SUSE, openSUSE, and Fedora. I don't know if there is specific list but a good place to start would those distributions which meet the Linux Standard Base (LSB). http://www.linuxfoundation.org/collaborate/workgroups/lsb
The views expressed in this post are the opinions of the Infosec Island member that posted this content. Infosec Island is not responsible for the content or messaging of this post.

Unauthorized reproduction of this article (in part or in whole) is prohibited without the express written permission of Infosec Island and the Infosec Island member that posted this content--this includes using our RSS feed for any purpose other than personal use.