如何知道我正在使用哪个Linux发行版?

时间:2022-09-29 07:17:33

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。我如何知道这是Ubuntu/Debian/Fedora或Redhat呢?

I uses /etc/init.d/serviced restart for restarting serevices, seems it is not Redhat family

我使用/etc/init.重新启动的服务,似乎不是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
[~]$

6 个解决方案

#1


29  

Try this:

试试这个:

cat /etc/*-release

You could also try /etc/*-version

您还可以尝试/etc/ -version。

#2


18  

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标准基础核心规范中。

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!

编辑:看起来你是在一个红帽系统。一个谷歌搜索你的uname输出表明是这样的。当然,这不是编程式!

#3


11  

/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-发行版,使其更容易确定具体的字符串,如发行版、主发行版/主发行版/网站等。

In the absence of /etc/lsb-release, its much more difficult, hence the creation of lsb-release.

在没有/etc/lsb版本的情况下,它的难度要大得多,因此创建了lsb版本。

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 /其他),查看/etc/ init是否。d是一个符号链接(rpm / RH distros)或一个目录(debian基于distros)。对于在根文件系统中出现的结构,你有一个很好的线索。

You can't please everyone :)

你不可能讨好每一个人:)

#4


5  

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

#5


2  

A list the release filenames for the most common distros: Release files

列出了最常见的发行版的版本文件名:发布文件。

And a function that might help you: Shell script

一个可以帮助你的函数:Shell脚本。

#6


1  

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代表企业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.)

是一个好的开始。(注意,当他们从Debian中拉出更改时,Ubuntu并没有修改/etc/debian_version,所以我的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。很好的电话,Tim Post和Alok。LSB的意义在于提供独立的方法去做事情。

#1


29  

Try this:

试试这个:

cat /etc/*-release

You could also try /etc/*-version

您还可以尝试/etc/ -version。

#2


18  

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标准基础核心规范中。

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!

编辑:看起来你是在一个红帽系统。一个谷歌搜索你的uname输出表明是这样的。当然,这不是编程式!

#3


11  

/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-发行版,使其更容易确定具体的字符串,如发行版、主发行版/主发行版/网站等。

In the absence of /etc/lsb-release, its much more difficult, hence the creation of lsb-release.

在没有/etc/lsb版本的情况下,它的难度要大得多,因此创建了lsb版本。

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 /其他),查看/etc/ init是否。d是一个符号链接(rpm / RH distros)或一个目录(debian基于distros)。对于在根文件系统中出现的结构,你有一个很好的线索。

You can't please everyone :)

你不可能讨好每一个人:)

#4


5  

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

#5


2  

A list the release filenames for the most common distros: Release files

列出了最常见的发行版的版本文件名:发布文件。

And a function that might help you: Shell script

一个可以帮助你的函数:Shell脚本。

#6


1  

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代表企业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.)

是一个好的开始。(注意,当他们从Debian中拉出更改时,Ubuntu并没有修改/etc/debian_version,所以我的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。很好的电话,Tim Post和Alok。LSB的意义在于提供独立的方法去做事情。