LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Distributions (https://www.linuxquestions.org/questions/linux-distributions-5/)
-   -   Determine version of Linux? (https://www.linuxquestions.org/questions/linux-distributions-5/determine-version-of-linux-4175446892/)

ghostware 01-23-2013 08:25 AM

Determine version of Linux?
 
Old school UNIX programmer now needing to deal with a lot of Linux versions (RedHat, SUSE, etc) on machines without documentation. Trying to label various machines distributions and only having marginal success, Tried old reliable uname command but Linux distributions are a lot more complicated and do not believe all information is captured I need is here and need more methods to distinguish versions.

As an example using uname command:

uname-s:Linux
uname-r:2.6.9-89.ELsmp
uname-v:#1 SMP Mon Apr 20 10:34:33 EDT 2009
uname-m:i686
uname-p:i686
uname-i:i386

No where in this does it tell me that this is a Red Hat system, something I am fairly sure it is. I think it is a version of Red Hat 5 and when I did a search I found these three systems matching kernel:
  • RedHatEnterpriseAS 4
  • RedHatEnterpriseWS 4
  • RedHatEnterpriseServer 5.2

Any programmatic way of further determining version? Pretty sure dealing with 8-10 versions of Red Hat, SUSE, Oracle Linux, etc and want to further distinguish them so can write adjustments to scripts appropriately.

thesnow 01-23-2013 08:29 AM

If it is Red Hat, check /etc/redhat-release

Code:

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.9 (Tikanga)

Other distributions may have a similar file, such as /etc/SuSE-release, or /etc/lsb-release

unSpawn 01-23-2013 09:32 AM

See rkh_dat_get_os_info()?

frankbell 01-23-2013 09:23 PM

Either of these commands

Code:

cat /etc/*version*
cat /etc/*release*

will work on most distros.

jmccue 01-24-2013 07:23 PM

Some distros are starting to use file /etc/os-release
Slackware v 14.0 now has the file and I think newer fedoras and red hats, some variables are suppose to match between distros. Slackware's version:
Quote:

NAME=Slackware
VERSION="14.0"
ID=slackware
VERSION_ID=14.0
PRETTY_NAME="Slackware 14.0"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:slackware:slackware_linux:14.0"
HOME_URL="http://slackware.com/"
SUPPORT_URL="http://www.linuxquestions.org/questions/slackware-14/"
BUG_REPORT_URL="http://www.linuxquestions.org/questions/slackware-14/"
So maybe check for /etc/os-release and if not found try the other methods described in this thread

John

YankeePride13 01-25-2013 03:31 PM

Code:

cat /etc/issue


All times are GMT -5. The time now is 10:08 AM.