determine-os.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:46:36 +0200
changeset 1905 fba288d59662
child 1912 8b81a8f0f692
permissions -rw-r--r--
Include only local subsections into TOC. This prevent duplication of TOC when build single page HTML document. Also this make unnecessary CSS hack to hide document title as top level section.

.. -*- coding: utf-8; -*-
.. include:: HEADER.rst

================
 Detect OS info
================
.. contents::
   :local:

uname
=====
::

  $ uname -a
  Linux poly.tech-recipes.com 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 i686 i386
  GNU/Linux

    kernel name:     Linux
    hostname:        poly.tech-recipes.com
    kernel release:  2.6.5-1.358
    kernel version:  #1 Sat May 8 09:04:50 EDT 2004

Linux version files
===================

See for file ``/etc/<distroname>-version`` or ``/etc/<distroname>-release``::

  $ cat determine-os.sh
    #!/bin/sh
    [ -e /etc/SuSE-release ] && echo This is a SuSE system.
    [ -e /etc/redhat-release ] && echo This is a redhat system.
    [ -e /etc/fedora-release ] && echo This is a fedora system.
    [ -e /etc/debian-version ] && echo This is a debian system.
    [ -e /etc/slackware-version ] && echo This is a slackware system.

See also list:

  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``

Kernel version info
===================

Commonly, distributions will leave tags in the kernel version string to identify
themselves. This can be found in the log files like ``/var/log/syslog`` or
``/var/log/messages``::

  $ cat /etc/issue

or::

  $ cat /proc/version

Even if you run a custom kernel, you might still get hints from the gcc version
like this one line from ``/var/log/syslog``::

  Feb 20 05:54:07 sarge kernel: nf3 (root@sarge) (gcc version 3.4.4 20050314 (prerelease)
  (Debian 3.4.3-13sarge1)) #1 PREEMPT Thu Nov 16 20:31:43 CET 2006

'lsb_release' command
=====================
::

  $ sudo apt-get install lsb-release

  $ lsb_release -s -i
  Debian

  $ lsb_release -s -c
  squeeze

  $ lsb_release -s -r
  6.0