This knowledge base article shows several different commands that may be used to determine the version of Linux that is running on the system being accessed, and what brand of Linux (i. e., Red Hat or SUSE.)
The basic operating system information command is uname, but this command does not tell which release of Linux is being used.
For example, note the output of these two commands. In both cases the version information can be determined from the output, but it is not obvious.
- On SUSE, running uname shows the following. The data returned from the uname command does not specifically indicate which operating system type is running.
$ uname -a
Linux acm-710 4.4.103-92.56-default #1 SMP Wed Dec 27 16:24:31 UTC 2017 (2fd2155) x86_64 x86_64 x86_64 GNU/Linux
- With Red Hat we see the information below. The el6 inicates Red Hat.
$ uname -a
Linux acm-701rh 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
The string of 2.6.32-431.el6.x86_64 represents Red Hat 6.5, but the specific string of Red Hat 6.5 is not part of the output.
There are several commands and methods that can be used to determine the Linux distribution installed. These include:
1. Login via a terminal
After a successful login, the banner that displays will show the Operating System information. For example,
login as: oracle
Using keyboard-interactive authentication.
Password: <enter oracle user password>
Last login: Tue Nov 30 11:12:32 2010 from 192.168.8.17
Kickstart-installed SuSE Linux Thu Oct 21 10:07:48 EDT 2018
login as: oracle
oracle@vm-support-42's password:<enter oracle user password>
Last login: Wed Nov 17 11:50:07 2010 from 192.168.8.19
Kickstart-installed Red Hat Linux Wed Oct 27 10:54:47 EDT 2018
2. Print out the version using the command cat /proc/version or uname -a
Platform version information is kept in the /proc/version file. Review of this file provides operating system information.
$ cat /proc/version
Linux version 2.6.27.19-5-default (geeko@buildhost) (gcc version 4.3.2 [gcc-4_3-branch revision 141291]
(SUSE Linux) ) #1 SMP 2009-02-28 04:40:21 +0100
$ cat /proc/version Linux version 2.6.32-431.el6.x86_64 ( mockbuild@x86-023.build.eng.bos.redhat.com) (gcc version 4.4.7
20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Sun Nov 10 22:19:54 EST 2013
$ uname -a
Linux acm-701rh 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
For reference, these values correspond to these versions of Red Hat:
uname -a output | Red Hat version |
2.6.18-128.el5 | RHEL 5 U3 |
2.6.18-308.el5 | RHEL 5 U8 |
2.6.18-348.e15 | RHEL 5 U9 |
2.6.18-371.e15 | RHEL 5 U10 |
2.6.18-398.e15 | RHEL 5 U11 |
2.6.32-71.e16 | RHEL 6 GA |
2.6.32-131.0.15.e16 | RHEL 6 U1 |
2.6.32-220.e16 | RHEL 6 U2 |
2.6.32-279.e16 | RHEL 6 U3 |
2.6.32-358.e16 | RHEL 6 U4 |
2.6.32-431.e16 | RHEL 6 U5 |
3. Linux command that can be used to determine the OS: lsb_release -a
Another Linux command that shows the operating system type is lsb_release -a.
$ lsb_release -a
LSB Version: n/a
Distributor ID: SUSE
Description: SUSE Linux Enterprise Server 12 SP2
Release: 12.2 Codename: n/a
$ lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0 noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0 amd64:printing-4.0-ia32:printing-4.0-noarch Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Release: 5.8 Codename: Tikanga
4. Check for the existence of certain operating system-specific files in the /etc directory
Another simple way to determine the operating system type is to check for the existence of certain OS-specific files in the /etc directory:
- On a SUSE system, these files begin with 'suse'.
- On a Red Hat system, these files begin with 'red'.
Files beginning with suse will not exist on a Red Hat system and files beginning with red will not exist on a SUSE system.
$ ls /etc/red*
ls: cannot access /etc/red*: No such file or directory
$ cd /etc
$ ls -la | grep -i suse
-rw-r--r-- 1 root root 17 Oct 25 2016 SUSE-brand
-rw-r--r-- 1 root root 377 Jun 14 2017 SUSEConnect.example
drwxr-xr-x 3 root root 4096 Feb 15 2018 susehelp.d
-rw-r--r-- 1 root root 215 Oct 25 2016 SuSE-release
$ ls /etc/suse*
ls: /etc/suse*: No such file or directory
$ ls -la | grep -i red
drwxr-xr-x. 2 root root 4096 Mar 1 2017 redhat-lsb
-rw-r--r--. 1 root root 55 Oct 30 2013 redhat-release l
rwxrwxrwx. 1 root root 14 Mar 1 2017 system-release -> redhat-release