如何知道我使用的是哪个 Linux 发行版?

Mit*_*ran 59 linux linux-distributions

如何知道我使用的是哪个 Linux 发行版?

uname -a

Linux xxxxxx.net 2.6.9-42.0.3.EL.wh1smp #1 SMP Fri Aug 14 15:48:17 MDT 2009 i686 i686 i386 GNU/Linux

我怎么知道这是 Ubuntu/Debian/Fedora 还是 Redhat?

我是/etc/init.d/serviced restart用来重启服务的,好像不是Redhat家族的

[itf][~]$ cat /etc/issue
cat: /etc/issue: No such file or directory
[itf][~]$ cat /etc/issue.net
cat: /etc/issue.net: No such file or directory
[itf][~]$ lsb_release -a
-sh: lsb_release: command not found
[itf][~]$ cat /etc/*-release
cat: /etc/*-release: No such file or directory
[itf][~]$ cat /etc/*-version
cat: /etc/*-version: No such file or directory
[itf][~]$ cat /etc/*release
cat: /etc/*release: No such file or directory
[itf][~]$ cat /etc/*_release
cat: /etc/*_release: No such file or directory
[itf][~]$ cat /etc/*version
cat: /etc/*version: No such file or directory
[itf][~]$
Run Code Online (Sandbox Code Playgroud)

小智 37

  • 在 Debian 中: /etc/debian_version

  • 在 Ubuntu 中: lsb_release -a or /etc/debian_version

  • 在红帽中: cat /etc/redhat-release

  • 在 Fedora 中: cat /etc/fedora-release

  • `lsb_release -a` 也适用于 Debian (squeeze)。 (4认同)
  • 他尝试了所有这些,请参阅他的源代码。 (2认同)
  • +1,“lsb_release -a”在红帽上为我工作。 (2认同)

小智 31

把事情简单化!

cat /etc/*release
Run Code Online (Sandbox Code Playgroud)


小智 15

您可以试试Novell 的这篇文章

如果您是系统的所有者,那么您就知道安装并运行的是哪个 Linux。本文将帮助您了解如何确定安装了哪个 Linux 发行版。您可以将其合并到您的应用程序中以检测 Linux 发行版。

  • `cat /etc/*release` 似乎适用于一些主流发行版。我使用 Ubuntu、Mint、Red Hat 和 Gentoo 进行了验证。 (6认同)

Yog*_*esh 5

所有符合系统都将具有/etc/os-release,它应该为您提供与分发等相关的信息

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/"
Run Code Online (Sandbox Code Playgroud)