Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 *versionfiles 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.

share|improve this question
Why do you need to know? Perhaps instead testing for common distribution-specific tools (package managers, for instance) will do what you want? – Daniel Pryden Oct 7 '11 at 21:21
Well, what I really want to know is if I can replicate the server as a virtual machine locally, and then install stuff on local virtual machine, then copy the binaries over to the remote machine. I thought finding out the correct platform would be a good starting point. – Billy Moon Oct 7 '11 at 21:29
1  
The above directory listing is incomplete (e.g. hosts is missing, init.d, rc*). Is this a test? – ott-- Oct 7 '11 at 21:38
How are you accessing this server? Is it possible that you don't have access to the server's filesystem directly, but are instead inside a chroot jail? – Daniel Pryden Oct 7 '11 at 21:52
I guess I could be inside a chroot jail - does this mean I can not find out what the underlying system is? – Billy Moon Oct 7 '11 at 22:03
show 3 more comments

migrated from stackoverflow.com Oct 10 '11 at 4:54

5 Answers

On most modern Linux distros, the following command will give you its information:

lsb_release -a
share|improve this answer

/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 
Red Hat--->/etc/redhat-release, /etc/redhat_version
Fedora-->/etc/fedora-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

See here for more details unix forum

share|improve this answer
unfortunately I don't have any files ending release or version in my etc directory – Billy Moon Oct 7 '11 at 21:32

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.

share|improve this answer
no release or version files in my /etc/ – Billy Moon Oct 7 '11 at 21:34
@BillyMoon I believe it is only recent that Linux distributions started to add the lsb_release utility on their distribution. lsb_release -a – Alpha01 Oct 7 '11 at 21:42
Thanks for the tip - does not help me this time unfortunately – Billy Moon Oct 7 '11 at 22:01

uname -a

Works always for any Tux

share|improve this answer
That reports the kernel version string, which could be very wrong if your host is running a kernel from a different distribution -- either on bare metal or because of a tool like OpenVZ or VServers. – sarnold Oct 9 '11 at 1:10
Yes, but I suppose in this case author of Q will know smth. about situation. "Foreign" kernel is rather odd case – Lazy Badger Oct 9 '11 at 1:42

cat /etc/issue might answer your question.

The distro makers are not friendly to you here. First, each one thinks it is the only one true way.

Most likely, instead of trying to sniff the distro, you should be looking in more detail at the particular question you actually need to answer. Focus on the functionality you are looking at, not the distro providing it. After all, a new version of a distro can turn around and go in the opposite direction on any particular axis.

share|improve this answer
2  
there is no /etc/issue on my server – Billy Moon Oct 7 '11 at 21:17
Yes. Note that /etc/issue may contain escape sequences such as \n and \l. To see what these mean, man 5 issue and man getty (the /etc/issue file is primarily intended for use by getty). Of course the owner of the system could edit /etc/issue for some nefarious reason. – Keith Thompson Oct 7 '11 at 21:18
I don't think /etc/issue is required to exist, or to contain any information about the distribution vendor. It commonly does, but I don't think you can rely on it. – Daniel Pryden Oct 7 '11 at 21:20
@DanielPryden well one learns something every day. I'd never run into the absence of one myself before. – bmargulies Oct 9 '11 at 23:50

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.