如何知道我使用的是哪个 Linux 发行版?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1864734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to know which Linux Distribution I'm using?
提问by Mithun Sreedharan
Moved to https://superuser.com/questions/80251/how-to-know-which-linux-distribution-im-using
移至https://superuser.com/questions/80251/how-to-know-which-linux-distribution-im-using
How to know which Linux Distribution I'm using?
如何知道我使用的是哪个 Linux 发行版?
uname -a gives 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 How can I know this is Ubuntu/Debian/Fedora or Redhat?
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 还是红帽?
I uses /etc/init.d/serviced restart for restarting serevices, seems it is not Redhat family
我用/etc/init.d/serviced restart重启服务,好像不是Redhat家族
Update:
更新:
[~]$ cat /etc/issue
cat: /etc/issue: No such file or directory
[~]$ cat /etc/issue.net
cat: /etc/issue.net: No such file or directory
[~]$ lsb_release -a
-sh: lsb_release: command not found
[~]$ cat /etc/*-release
cat: /etc/*-release: No such file or directory
[~]$ cat /etc/*-version
cat: /etc/*-version: No such file or directory
[~]$ cat /etc/*release
cat: /etc/*release: No such file or directory
[~]$ cat /etc/*_release
cat: /etc/*_release: No such file or directory
[~]$ cat /etc/*version
cat: /etc/*version: No such file or directory
[~]$
回答by Dumb Guy
Try this:
尝试这个:
cat /etc/*-release
You could also try /etc/*-version
你也可以试试 /etc/*-version
回答by Tim Post
/etc/issue or /etc/issue.net give a good clue. Newer distros provide /etc/lsb-release which make it easier to determine exact strings progmatically, i.e. distro name / major & minor release / web site, etc.
/etc/issue 或 /etc/issue.net 提供了一个很好的线索。较新的发行版提供了 /etc/lsb-release ,它可以更容易地以编程方式确定确切的字符串,即发行版名称/主要和次要版本/网站等。
In the absence of /etc/lsb-release, its much more difficult, hence the creation of lsb-release.
在没有 /etc/lsb-release 的情况下,它要困难得多,因此创建 lsb-release。
As Alok said, it looks like you are on a rather ancient (or extremely sparse) system. I don't think this is a case that you can (reliably) progmatically determine with a few lines of code.
正如 Alok 所说,看起来你在一个相当古老(或极其稀疏)的系统上。我不认为这是您可以(可靠地)通过几行代码以编程方式确定的情况。
If all else fails, check to see what kind of package manager is in use (apt / rpm / others), check to see if /etc/init.d is a symlink (rpm / RH distros) or a directory (debian based distros) .. and you have a pretty good clue as to what you can expect to be present in the root file system as far as structure.
如果所有其他方法都失败,请检查正在使用的包管理器类型(apt / rpm / others),检查 /etc/init.d 是符号链接(rpm / RH 发行版)还是目录(基于 debian 的发行版) ) .. 就结构而言,您对根文件系统中可能存在的内容有一个很好的线索。
You can'tplease everyone :)
你不能取悦所有人:)
回答by Alok Singhal
If you have lsb_release
command,
如果你有lsb_release
命令,
lsb_release -a
will tell you (or just use lsb_release -i
).
会告诉你(或只是使用lsb_release -i
)。
lsb_release
is in Linux Standard Base Core Specification.
lsb_release
在Linux Standard Base Core Specification 中。
Edit: Looks like you're on a Red Hat system. A google search on your uname
output suggests so. This is not programmatic, of course!
编辑:看起来您使用的是 Red Hat 系统。对您的uname
输出的谷歌搜索表明如此。这当然不是程序化的!
回答by Peter Cordes
EL stands for Enterprise Linux in this case, so I think RedHat or a clone (like CentOS). I don't know a good way to programatically find out what distro you're on; there's a few different clues for each one.
在这种情况下,EL 代表 Enterprise Linux,所以我认为 RedHat 或克隆(如 CentOS)。我不知道以编程方式找出您正在使用的发行版的好方法;每一个都有一些不同的线索。
cat /etc/redhat_release
cat /etc/debian_version
is a good start. (Note the Ubuntu doesn't modify /etc/debian_version
when they pull changes from Debian, so my Ubuntu Karmic system has squeeze/sid in debian_version.)
是一个好的开始。(注意 Ubuntu/etc/debian_version
在从 Debian 中提取更改时不会进行修改,因此我的 Ubuntu Karmic 系统在 debian_version 中有挤压/sid。)
Edit: forgot about lsb. Good call, Tim Post and Alok. The whole point of LSB is to give distro-independent ways to do things.
编辑:忘记了 lsb。很好,蒂姆·波斯特和阿洛克。LSB 的全部意义在于提供独立于发行版的做事方式。
回答by stefanB
Seems like here's some info:
好像这里有一些信息:
> cat /etc/issue
Welcome to SUSE LINUX Enterprise Server 9 (i586) - Kernel \r (\l).
> uname -a
Linux boxname 2.6.5-7.244-smp #1 SMP Mon Dec 12 18:32:25 UTC 2005 i686 athlon i386 GNU/Linux
> cat /etc/*-release
SUSE LINUX Enterprise Server 9 (i586)
VERSION = 9
PATCHLEVEL = 3
回答by pcp
A list the release filenames for the most common distros: Release files
列出最常见发行版的发布文件名: 发布文件
And a function that might help you: Shell script
还有一个可能对您有帮助的函数: Shell 脚本