How to get Linux distribution name and version?

后端 未结 8 2005
轻奢々
轻奢々 2021-02-04 06:28

In Windows I read the registry key SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName to get the full name and version of the OS.

But in Linux, th

8条回答
  •  佛祖请我去吃肉
    2021-02-04 07:11

    /etc/os-release is available on at least both CentOS 7 and Ubuntu 16.04, which makes it more cross-platform than lsb_release (not on CentOS) or /etc/system-release (not on Ubuntu).

    $ cat /etc/os-release
    

    Example:

    NAME=Fedora
    VERSION="17 (Beefy Miracle)"
    ID=fedora
    VERSION_ID=17
    PRETTY_NAME="Fedora 17 (Beefy Miracle)"
    ANSI_COLOR="0;34"
    CPE_NAME="cpe:/o:fedoraproject:fedora:17"
    HOME_URL="https://fedoraproject.org/"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    

提交回复
热议问题