Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How to know version of a CentOS server without access to any graphical interface? I've tried several commands:

# cat /proc/version
Linux version 2.6.18-128.el5 (mockbuild@hs20-bc1-7.build.redhat.com)
(gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) #1 SMP Wed Dec 17 11:41:38 EST 2008

# cat /etc/issue
Red Hat Enterprise Linux Server release 5.3 (Tikanga)

but which one is correct: 4.1.2-4 from /proc/version or 5.3 from /etc/issue?

share|improve this question

3 Answers 3

up vote 10 down vote accepted

As you can see in /etc/issue, you're using CentOS 5.3. (It says Red Hat because CentOS is based upon the RH sources, and some software checks /etc/issue to identify the distro in use; thus, they'd fail if this was changed to CentOS).

The 4.1.2-4 in /proc/version refers to the version of the gcc C compiler used to build the kernel.

share|improve this answer
3  
I'll just add, what You could use uname -a to detect, if it 32 or 64 bit compatible. –  Fedir May 31 '13 at 9:46
1  
On CentOS 7, 'cat /etc/issue' yields gobbledygook: \S Kernel \r on an \m –  Urhixidur Jul 8 at 16:09

In cases like CentOS the actual version is usually placed in /etc/*elease.

cat /etc/*elease

granted this file usually holds the version of the entire OS minus the kernel (since you can choose which to load). This file will have the same information as /etc/issue but with CentOS instead of RedHat

share|improve this answer
    
cat /etc/*release will work too, and you are not omitting a letter of what are you looking for ;) because elease is not always easy to guess. * can be nothing, all, one or more items at time. Thank you, i always forgot the way to get the release version. –  erm3nda May 22 at 17:11
1  
The reason I leave the "R" off is because in some cases the "R" in "release" is capitalized. –  h3rrmiller Jun 1 at 19:08
    
Oh! thank you :) –  erm3nda Jun 2 at 8:03
    
Just to say, doing ls /etc/*elease on my system gives /etc/centos-release /etc/redhat-release /etc/system-release. So I'm guessing from all this that the release files tend to be in /etc/*-release - but possibly with some capitalisation. –  mwfearnley Aug 7 at 12:35

The most reliable way of finding MAJOR version of CentOS (5 or 6 etc) is:

# rpm -q --queryformat '%{VERSION}' centos-release
6

For RHEL do this:

# rpm -q --queryformat '%{RELEASE}' redhat-release-server | awk -F. '{print $1}'
7

The only portable way of finding out a version is:

# cat /etc/redhat-release | grep -oE '[0-9]+\.[0-9]+'
6.5
share|improve this answer
    
Can be simplified to: cat /etc/redhat-release | grep -o '[0-9]\.[0-9]' –  Dave Johansen Jul 31 at 23:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.