Determine Linux distribution
I am trying to determine what flavor of linux server is running. I am not trying to determine the kernel version - but rater the distributor.
gcc is installed, and in the version output, it says RedHat
# gcc --version
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-11)
Does this mean I can safely assume my server is a RedHat server. Is there a better - 100% bulletproof method to find this out? Also for other linux flavors - not just this server?
Edit: contents of /etc/
in case it helps - but I would like a solution that works for other versions of linux too.
# ls /etc/
./ backupmxhosts domainusers host.conf localdomains mailips pam.d/ relayhosts shadow trustedmailhosts
../ bashrc* exim.conf inputrc localtime man.config passwd resolv.conf skipsmtpcheckhosts userdomains
DIR_COLORS cron.deny exim.pl ld.so.cache lynx.cfg mtab profile secondarymx spammeripblocks vimrc
aliases demodomains exim.pl.local* ld.so.conf mail/ my.cnf profile.d/ senderverifybypasshosts sudoers
antivirus.exim demouids group localaliases mailhelo nsswitch.conf protocols services termcap
I have no *release
or *version
files in /etc/
# ls /etc*release; ls /etc/*version
/bin/ls: /etc/*release: No such file or directory
/bin/ls: /etc/*version: No such file or directory
I tried LSB
# lsb_release -a
LSB Version:
Distributor ID: n/a
Description: (none)
Release: n/a
Codename: n/a
Also - I guess I am inside a chroot jail
(not really sure what that is) which could likely be the cause for this issue.
Updated:
I think this does it for me. I think I can safely assume I am using cent-os.
# cat /proc/version
Linux version 2.6.9-103.plus.c4smp ([email protected]) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-11)) #1 SMP Wed Dec 21 16:17:23 EST 2011
Solution 1:
cat /proc/version
Examples:
-
Ubuntu:
$ cat /proc/version Linux version 3.11.0-13-generic (buildd@roseapple) (gcc version 4.8.1 \ (Ubuntu/Linaro 4.8.1-10ubuntu8) ) #20-Ubuntu SMP Wed Oct 23 07:38:26 UTC 2013
-
Red Hat / CentOS:
$ cat /proc/version Linux version 2.6.32-220.13.1.el6.x86_64 ([email protected]) \ (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Apr 17 23:56:34 BST 2012
See also How To Know Which Linux Distribution You Are Using?
Solution 2:
On most modern Linux distros, the following command will give you its information:
lsb_release -a
Solution 3:
/etc/issue
might be a good starting point.
More could be found by inspecting the info files for different distributions:
Novell SuSE /etc/SuSE-release
OpenSuSE /etc/SuSE-release, /etc/os-release
Red Hat,CentOS /etc/redhat-release, /etc/redhat_version
Fedora /etc/fedora-release, /etc/redhat-release, /etc/os-release
Slackware /etc/slackware-release, /etc/slackware-version
Debian /etc/debian_release, /etc/debian_version
Mandrake /etc/mandrake-release
Yellow dog /etc/yellowdog-release
Sun JDS /etc/sun-release
Solaris/Sparc /etc/release
Gentoo /etc/gentoo-release
Amazon Linux /etc/system-release
PLD Linux /etc/pld-release, /etc/os-release
ArchLinux /etc/arch-release, /etc/os-release
See Unix forum for more details.
Solution 4:
If /etc/issue
is missing, there may be one or more /etc/*_release
files.
For example, my Ubuntu system has /etc/lsb-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.04
DISTRIB_CODENAME=natty
DISTRIB_DESCRIPTION="Ubuntu 11.04"
A friend's CentOS system (based on Red Hat) has /etc/redhat-release
:
CentOS release 5.6 (Final)
I don't know how universal this is.