determine-os.rst
changeset 1905 fba288d59662
child 1912 8b81a8f0f692
equal deleted inserted replaced
1904:78357d58b7ab 1905:fba288d59662
       
     1 .. -*- coding: utf-8; -*-
       
     2 .. include:: HEADER.rst
       
     3 
       
     4 ================
       
     5  Detect OS info
       
     6 ================
       
     7 .. contents::
       
     8    :local:
       
     9 
       
    10 uname
       
    11 =====
       
    12 ::
       
    13 
       
    14   $ uname -a
       
    15   Linux poly.tech-recipes.com 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 i686 i386
       
    16   GNU/Linux
       
    17 
       
    18     kernel name:     Linux
       
    19     hostname:        poly.tech-recipes.com
       
    20     kernel release:  2.6.5-1.358
       
    21     kernel version:  #1 Sat May 8 09:04:50 EDT 2004
       
    22 
       
    23 Linux version files
       
    24 ===================
       
    25 
       
    26 See for file ``/etc/<distroname>-version`` or ``/etc/<distroname>-release``::
       
    27 
       
    28   $ cat determine-os.sh
       
    29     #!/bin/sh
       
    30     [ -e /etc/SuSE-release ] && echo This is a SuSE system.
       
    31     [ -e /etc/redhat-release ] && echo This is a redhat system.
       
    32     [ -e /etc/fedora-release ] && echo This is a fedora system.
       
    33     [ -e /etc/debian-version ] && echo This is a debian system.
       
    34     [ -e /etc/slackware-version ] && echo This is a slackware system.
       
    35 
       
    36 See also list:
       
    37 
       
    38   Novell SuSE
       
    39     ``/etc/SuSE-release``
       
    40   Red Hat
       
    41     ``/etc/redhat-release``, ``/etc/redhat_version``
       
    42   Fedora
       
    43     ``/etc/fedora-release``
       
    44   Slackware
       
    45     ``/etc/slackware-release``, ``/etc/slackware-version``
       
    46   Debian
       
    47     ``/etc/debian_release``, ``/etc/debian_version``,
       
    48   Mandrake
       
    49     ``/etc/mandrake-release``
       
    50   Yellow dog
       
    51     ``/etc/yellowdog-release``
       
    52   Sun JDS
       
    53     ``/etc/sun-release``
       
    54   Solaris/Sparc
       
    55     ``/etc/release``
       
    56   Gentoo
       
    57     ``/etc/gentoo-release``
       
    58 
       
    59 Kernel version info
       
    60 ===================
       
    61 
       
    62 Commonly, distributions will leave tags in the kernel version string to identify
       
    63 themselves. This can be found in the log files like ``/var/log/syslog`` or
       
    64 ``/var/log/messages``::
       
    65 
       
    66   $ cat /etc/issue
       
    67 
       
    68 or::
       
    69 
       
    70   $ cat /proc/version
       
    71 
       
    72 Even if you run a custom kernel, you might still get hints from the gcc version
       
    73 like this one line from ``/var/log/syslog``::
       
    74 
       
    75   Feb 20 05:54:07 sarge kernel: nf3 (root@sarge) (gcc version 3.4.4 20050314 (prerelease)
       
    76   (Debian 3.4.3-13sarge1)) #1 PREEMPT Thu Nov 16 20:31:43 CET 2006
       
    77 
       
    78 'lsb_release' command
       
    79 =====================
       
    80 ::
       
    81 
       
    82   $ sudo apt-get install lsb-release
       
    83 
       
    84   $ lsb_release -s -i
       
    85   Debian
       
    86 
       
    87   $ lsb_release -s -c
       
    88   squeeze
       
    89 
       
    90   $ lsb_release -s -r
       
    91   6.0
       
    92