How to Identify what RHEL version (in linux command) you are Running

RHEL version Commands in Linux

As a new Red Hat Enterprise Linux user, it may be difficult to figure out how to figure out what version of RHEL you are running, especially if you have multiple versions on multiple servers. Here are 3 easy methods for determining your version and architecture. These examples should work in any Red Hat Linux environment, but these examples are specific to RHEL.

First Method for RHEL Version Command Linux RHEL Command

Find Red Hat Enterprise Linux version using /etc/redhat-release file  In this example we will be using the cat command to print the contents of the /etc/redhat-release file to the screen:

$ cat /etc/redhat-release

Sample output:

Red Hat Enterprise Linux Server release 6.5 (Santiago)

In this example, RHEL is version 6.5. Santiago is the codename of the Linux project that is denoted by version 6.5 (For example, Ubuntu names all its releases after animals in alphabetical order by version.)

Second Method: Determine what version of Red Hat Enterprise Linux is running using lsb_release commandEnterprise Linux RHEL identification

First, we will install a package called redhat-lsb-core using the yum command. We need root privileges to do this, so we will invoke it by using sudo immediately before the command to get super user privileges. This prevents us from having to log in as root, which is a security risk:

$ sudo yum install redhat-lsb-core

The output should look something like this:

Loaded plugins: product-id, protectbase, rhnplugin
This system is receiving updates from RHN Classic or RHN Satellite.
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package redhat-lsb-core.x86_64 0:4.0-7.el6 will be installed
epel/filelists_db                                        | 8.1 MB     00:02     
ksplice-uptrack/filelists                                | 2.2 kB     00:00     
rhel-x86_64-server-6/filelists                           |  28 MB     00:04     
rhel-x86_64-server-6-debuginfo/filelists                 |  38 MB     00:05     
rhel-x86_64-server-optional-6/filelists                  |  10 MB     00:01     
rhel-x86_64-server-optional-6-debuginfo/filelists        |  34 MB     00:05     
rhel-x86_64-server-supplementary-6/filelists             | 1.5 MB     00:00     
rhel-x86_64-server-supplementary-6-debuginfo/filelists   |  863 B     00:00     
--> Processing Dependency: perl-Test-Simple for package: redhat-lsb-core-4.0-7.el6.x86_64
--> Processing Dependency: perl-CGI for package: redhat-lsb-core-4.0-7.el6.x86_64
--> Processing Dependency: /usr/bin/pax for package: redhat-lsb-core-4.0-7.el6.x86_64
--> Processing Dependency: /usr/bin/patch for package: redhat-lsb-core-4.0-7.el6.x86_64
--> Processing Dependency: /bin/gettext for package: redhat-lsb-core-4.0-7.el6.x86_64
--> Processing Dependency: /usr/bin/msgfmt for package: redhat-lsb-core-4.0-7.el6.x86_64
--> Running transaction check
---> Package gettext.x86_64 0:0.17-16.el6 will be installed
--> Processing Dependency: cvs for package: gettext-0.17-16.el6.x86_64
---> Package patch.x86_64 0:2.6-6.el6 will be installed
---> Package pax.x86_64 0:3.4-10.1.el6 will be installed
---> Package perl-CGI.x86_64 0:3.51-136.el6 will be installed
---> Package perl-Test-Simple.x86_64 0:0.92-136.el6 will be installed
--> Running transaction check
---> Package cvs.x86_64 0:1.11.23-16.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package             Arch      Version            Repository               Size
================================================================================
Installing:
 redhat-lsb-core     x86_64    4.0-7.el6          rhel-x86_64-server-6     25 k
Installing for dependencies:
 cvs                 x86_64    1.11.23-16.el6     rhel-x86_64-server-6    712 k
 gettext             x86_64    0.17-16.el6        rhel-x86_64-server-6    1.8 M
 patch               x86_64    2.6-6.el6          rhel-x86_64-server-6     91 k
 pax                 x86_64    3.4-10.1.el6       rhel-x86_64-server-6     69 k
 perl-CGI            x86_64    3.51-136.el6       rhel-x86_64-server-6    209 k
 perl-Test-Simple    x86_64    0.92-136.el6       rhel-x86_64-server-6    112 k
 
Transaction Summary
================================================================================
Install       7 Package(s)
 
Total download size: 3.0 M
Installed size: 0  
Is this ok [y/N]: y
Downloading Packages:
(1/7): cvs-1.11.23-16.el6.x86_64.rpm                     | 712 kB     00:00     
(2/7): gettext-0.17-16.el6.x86_64.rpm                    | 1.8 MB     00:00     
(3/7): patch-2.6-6.el6.x86_64.rpm                        |  91 kB     00:00     
(4/7): pax-3.4-10.1.el6.x86_64.rpm                       |  69 kB     00:00     
(5/7): perl-CGI-3.51-136.el6.x86_64.rpm                  | 209 kB     00:00     
(6/7): perl-Test-Simple-0.92-136.el6.x86_64.rpm          | 112 kB     00:00     
(7/7): redhat-lsb-core-4.0-7.el6.x86_64.rpm              |  25 kB     00:00     
--------------------------------------------------------------------------------
Total                                           3.1 MB/s | 3.0 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : cvs-1.11.23-16.el6.x86_64                                    1/7 
  Installing : gettext-0.17-16.el6.x86_64                                   2/7 
  Installing : perl-Test-Simple-0.92-136.el6.x86_64                         3/7 
  Installing : pax-3.4-10.1.el6.x86_64                                      4/7 
  Installing : perl-CGI-3.51-136.el6.x86_64                                 5/7 
  Installing : patch-2.6-6.el6.x86_64                                       6/7 
  Installing : redhat-lsb-core-4.0-7.el6.x86_64                             7/7 
  Verifying  : patch-2.6-6.el6.x86_64                                       1/7 
  Verifying  : perl-CGI-3.51-136.el6.x86_64                                 2/7 
  Verifying  : redhat-lsb-core-4.0-7.el6.x86_64                             3/7 
  Verifying  : pax-3.4-10.1.el6.x86_64                                      4/7 
  Verifying  : gettext-0.17-16.el6.x86_64                                   5/7 
  Verifying  : perl-Test-Simple-0.92-136.el6.x86_64                         6/7 
  Verifying  : cvs-1.11.23-16.el6.x86_64                                    7/7 
 
Installed:
  redhat-lsb-core.x86_64 0:4.0-7.el6                                            
 
Dependency Installed:
  cvs.x86_64 0:1.11.23-16.el6        gettext.x86_64 0:0.17-16.el6              
  patch.x86_64 0:2.6-6.el6           pax.x86_64 0:3.4-10.1.el6                 
  perl-CGI.x86_64 0:3.51-136.el6     perl-Test-Simple.x86_64 0:0.92-136.el6    
 
Complete!

Now type the following command:

$ lsb_release -a

Output:

LSB Version:	:base-4.0-amd64:base4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.5 (Santiago)
Release:         6.5
Codename:         Santiago

This method finds the base version and returns who distributed the version of Linux you are using (Fedora, Red Hat, Ubuntu) and the version number. lsb is simply a command much like ls, which lists files and folders, for the base version of the operating system. You will come to find when writing in code and especially within php, thinking on your feet to know quick linux commands can make all the difference. That is why we recommend every take our free jquery tutorial as well since it is yet another skill you would benefit from having

Third Method: Find RHEL version command using /etc/issue file Type the following cat command in a terminal window:

$ cat /etc/issue

Output:

Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel \r on an \m

The /etc/issue file is specifically designed to display the architecture and the kernel number and build when a text login screen is encountered, such as running a production server in multi-user textual mode. At the beginning of each session, the \r and \m will show the kernel number and the processor type.

Now we know how to find the version number a multitude of different ways. These can be used by themselves, or in a script to pass the version information on to a different program. No matter what the reason, not knowing the correct version and architecture can make upgrades and maintenance a problem for anyone. Fortunately, as we have shown, finding this information is easy.

FOLLOW US ON: