How to discover what Linux distribution is in use

前端 未结 12 1527
青春惊慌失措
青春惊慌失措 2020-12-02 20:46

Sometimes I need to access some servers running Linux (or maybe another Unix-like SO), but I don\'t know how to verify which distribution is in use on the server (there are

相关标签:
12条回答
  • 2020-12-02 21:30

    NeoFetch

    ... is a quite professional BASH script that should have all the info you might desire.

    (Disclaimer: I am not affiliated with it)

    Usage

    neofetch --stdout | grep '^OS: ' | sed -e 's/OS:[[:space:]]\+//'
    

    might give:

    Debian GNU/Linux 11 (bullseye) x86_64

    but there is much more info.

    Installation

    Options:

    1. system packaage neofetch

    2. If that is not available, either see the official installation instructions

    3. or for a hacky one-time use - if you have faith and an internet connection - you could use:

      wget 'https://raw.githubusercontent.com/dylanaraps/neofetch/master/neofetch' \
          && bash neofetch --stdout \
          && rm neofetch
      
    0 讨论(0)
  • 2020-12-02 21:31

    The proc file system: A directory in Linux with all the hardware level information. So just type

    cd /proc/
    

    There you will find a gold mine of information stored in a text file for all the arbitrary information about the system.

    0 讨论(0)
  • 2020-12-02 21:36

    In my .cshrc I have

    setenv DISTRO `sed -e 's/.*(//' -e 's/)).*//' /proc/version`
    

    For ksh / Bash users, I presume it translates to

    export DISTRO=`sed -e 's/.*(//' -e 's/)).*//' /proc/version`
    

    and of course this may not work for your favorite distribution. (I have had issues with Oracle's Unbreakable Linux giving something similar to Redhat, but it was good enough for my purposes.)

    Update August 2016 I have not used Linux in this way for a while (2008 is a long time ago). It seems that this does not work anymore for the systems I now have.

    0 讨论(0)
  • 2020-12-02 21:36

    Try uname -a

    0 讨论(0)
  • 2020-12-02 21:37

    This is, annoyingly, a harder problem than it appears.

    For Linux systems, use lsb_release.

    $ lsb_release --all
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 8.04.1
    Release:        8.04
    Codename:       hardy
    $ lsb_release -i
    Distributor ID: Ubuntu
    

    This has the limitation that lsb_release works only for Linux releases.

    For all Unix systems, you can also parse up uname.

    $ uname -a
    Linux blue-laptop 2.6.24-21-generic #1 SMP Tue Oct 21 23:43:45 UTC 2008 i686 GNU/Linux
    

    You can find some information about the systems and distributions at the uname Wikipedia page.

    0 讨论(0)
  • 2020-12-02 21:38
    cat /etc/*release
    

    Most distributions put a release file in /etc/ (like /etc/redhat-release, /etc/gentoo-release, etc.) which usually has the version number of your distribution in it.

    0 讨论(0)
提交回复
热议问题