heidi has asked for the wisdom of the Perl Monks concerning the following question:

hi monks, whats the command to find out the version of the operating system i have. i have Redhat linux 9.0 but commands like uname -v -s -i -r doesnt give any information on redhat and 9.0, can anyone give me the command for it. thanks.

2006-10-16 Retitled by Arunbear, as per Monastery guidelines
Original title: 'command for finding out the operating system in linux.'

  • Comment on (OT) command for finding out which distribution of Linux is being used

Replies are listed 'Best First'.
Re: (OT) command for finding out which distribution of Linux is being used
by ikegami (Patriarch) on Oct 16, 2006 at 05:21 UTC

    I don't know the answer to your question, but I can tell you why uname doesn't help.

    RedHat is not an operating system. RedHat is a distribution (which includes Linux, an OS). $^O can be used to determine which OS is being used, but it won't tell you which distribution of Linux is being used.

      RedHat is not an operating system.

      Well, that depends on your definition of "operating system". What some call "operating system", others call "kernel". What others call "operating system", some call "distribution". And yet other people name the kernel + /usr "operating system".

        Yes, people often use terms in a misleading way, because they make up their own definition, or because they follow a convention or habit, which may be wrong. People often say America when they refer to the USA, which is plain wrong. America is a continent, not a nation, a country or a collection of states.

        For some reason there is the distinction between kernel, system software and applications to keep things apart.

        The kernel alone makes no operating system. An operating system is the functional unit comprised by the kernel and the system software. Period. In that sense referring to Linux as an operating system is wrong: an operating system with the Linux kernel is called more accurately Linux/GNU (or GNU/Linux, there's also GNU/Hurd), since the kernel is called Linux, and the system software is GNU.

        OTOH it can be debated whether the different Linux distributions (Debian, Mandrake, Gentoo, RedHat, SuSE to name a few) differ so much in their system software that their respective undelying OS may be called an own distinct operating system. Since they ship oodles of applications, some of which are tightly integrated into the system software via dependencies, they are distributions.

        IMHO the *BSD variants show that distinction best: there's the kernel and the system software in a minimal install. All else lives in the ports tree.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

        Well, that depends on your definition of "operating system".

        The expression may have more than one meaning, but not as far as Perl and (apparently) uname are concerned. I was speaking in context.

Re: (OT) command for finding out which distribution of Linux is being used
by RobPayne (Chaplain) on Oct 16, 2006 at 05:17 UTC
    The following will give you the redhat version:
    $ cat /etc/redhat-release
    
    Similarly, on fedora it is:
    $ cat /etc/fedora-release
    
    HTH! That's not really perl-related, though. You might want to ask this type of question in the chatterbox, in the future.
      And just in case, for Debian and related distributions, the release information is stored into
      /etc/debian_version
      And slackare uses
      /etc/slackware-version
        And just in case, for Debian and related distributions, the release information is stored into

        And FWIW in CRUX I can use the crux command, which in turn is a script which just echoes the wanted info, hardcoded there. The lesson to be learnt here is that not only the question has nothing to do with Perl, but also that it is one that hardly has an answer, since it's up to each distro to provide that info, and each distro provides it, or possibly doesn't, in its own way, i.e. there appears not to be a standard.

        However as fenLisesi++ points out, some more info seems to be available in /proc/version, specifically in the C compiler description: I've now checked 6 systems which comprise 4 different distros, namely CRUX, Mandriva, Debian and Gentoo; but I don't have the slightest idea how all this may be in general - and there are far many more distros out there...

      thanks for the answer. as you said, i will ask such questions in chatter box henceforth. thanks again.
Re: (OT) command for finding out which distribution of Linux is being used
by fenLisesi (Priest) on Oct 16, 2006 at 07:20 UTC
    cat /proc/version usually gives you more information than uname -a. If you use the system builtin to call these commands from perl, remember that it returns true on failure and make sure you use the LIST form or at least avoid shell-metacharacters and shell-pattern-matching-characters in the string that you pass to system.

    Here is a shell session on my system:

    I think most monks prefer to field non-perl questions in the Chatterbox.

    Update: Added <readmore>

Re: (OT) command for finding out which distribution of Linux is being used
by xorl (Deacon) on Oct 17, 2006 at 15:27 UTC

    I'm going to try and get this thread back on track, after all I'm sure there is somewhere else we can discuss if America is a country, continent, ship, band, or something else...

    As mentioned in previous posts, you can check:
    /etc/redhat-release
    /etc/fedora-release
    /etc/debian_version
    /etc/slackware-version

    to get the version for those distros. My question then is, Is it safe to say that /etc/*(-|_)release will have the distro version? (I haven't tested that regex yet so someone will hopefully correct me if I was wrong there).

    The next question is, do you really need do know the distro? Isn't is better to test if some module or function exists, or check to see where some file location is? What are you trying to do?

    Finally, I'm glad to see I'm not the only person still using RH9.

      The file /etc/issue is intended to describe the system to the user at the login prompt (when not using these new-fangled X terminals).

      It can be altered by the sysadmin, but generally isn't.

      On Ubuntu Dapper it contains (by default):

      Ubuntu 6.06.1 LTS \n \l
      and I'd expect it to be populated on all/most other distros. Might be of use.

      And out of interest...why do you want this info? ;-)