is it SUSE or RHEL or Debian. How to detect programmatically?

Hi Gurus,

I want to programmatically detect what Linux flavour I have in my m/c, detailed OS-name and its version,
e.g. is it RHEL, SUSE, Debian etc.

----------------------------------------------------------------
Flavour OS-Nname version
----------------------------------------------------------------
RHEL3 RHEL 3.2
RHEL4 RHEL 4
RHEL5 RHEL 5.1
SLES9 SLES 10
SLES10 SLES 9
----------------------------------------------------------------

Thee is structre

"struct utsname uts;"

This structure doesn't give me above information. This can be found by looing at /etc/issue or /etc/redhat-release.

I appreciate if anyboy gives me hint/pointer how can I detect programmatically .

Some sample output here below,

mycomnp> cat /etc/issue

Welcome to SUSE Linux Enterprise Server 10 (ia64) - Kernel \r (\l).

mycomnp> uname -a
Linux mynode 2.6.16.21-0.8-default #1 SMP Mon Jul 3 18:25:39 UTC 2006 ia64 ia64 ia64 GNU/Linux

Output of utsname structure:
main()
{
struct utsname sys_inf;

uname\(&sys_inf\);

printf\("System name - %s \\n", sys_inf.sysname\);
printf\("Nodename    - %s \\n", sys_inf.nodename\);
printf\("Release     - %s \\n", sys_inf.release\);
printf\("Version     - %s \\n", sys_inf.version\);
printf\("Machine     - %s \\n", sys_inf.machine\);

}

System name - Linux
Nodename - mynode
Release - 2.6.16.21-0.8-default
Version - #1 SMP Mon Jul 3 18:25:39 UTC 2006
Machine - ia64

Thanks in advance

  • Krishna

I know that RHEL, and suse usually have a file named "/etc/issue", which contains Distribution and Version info, but I'm not so sure about debian.

Hope that helps.

edit: whoops, didnt see you're part about /etc/issue...sorry.

You can use the command as follows.
#uname -a

Refer the man page of 'uname' for more details.

Also look at the /etc/*release file.

Deleted by myself,

reason: didn't read whole post.