确定 Redhat Linux 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15164520/
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
Determine Redhat Linux Version
提问by Satish
How do I determine which RedHat
Linux version I am running?
如何确定RedHat
我运行的是哪个Linux 版本?
Here's what I've read:
这是我读过的:
/etc/redhat-release
file contains the version, but anybody can tamper with that file.- people say
uname
command, but you can install any kernel on Redhat.
/etc/redhat-release
文件包含版本,但任何人都可以篡改该文件。- 人们说
uname
命令,但你可以在 Redhat 上安装任何内核。
If I am running redhat 5.1 and someone upgrade it with 5.2 or 5.x, what determines the version of RedHat?
如果我运行的是 redhat 5.1 并且有人用 5.2 或 5.x 升级它,那么什么决定了 RedHat 的版本?
even lsb_release -a
read /etc/redhat-release file.
甚至lsb_release -a
阅读 /etc/redhat-release 文件。
采纳答案by mikyra
If "anybody" has root access to your machine to either change /etc/redhat-release or install an alternate kernel you're most probably in bigger trouble than determining the redhat version of your system.
如果“任何人”对您的机器具有 root 访问权限以更改 /etc/redhat-release 或安装备用内核,那么您很可能会遇到比确定系统的 redhat 版本更大的麻烦。
Just use the value pointed out by /etc/redhat-release or even better in terms of portability use the output of lsb_release as this is exactly the purpose they were made for.
只需使用 /etc/redhat-release 指出的值,或者在可移植性方面甚至更好,使用 lsb_release 的输出,因为这正是它们的目的。
With "anybody" being able to do anything with your system there is no other chance at all.
“任何人”都可以对您的系统执行任何操作,因此根本没有其他机会。
回答by Tim
Try this command:
试试这个命令:
rpm -qa | grep release
for instance on my machine I get this
例如在我的机器上我得到这个
redhat-release-workstation-6Workstation-6.4.0.4.el6.x86_64
redhat-release-workstation-6Workstation-6.4.0.4.el6.x86_64
回答by Nullpointer
You can use the lsb_release command on recent linux distributions. If you issue:
您可以在最近的 linux 发行版上使用 lsb_release 命令。如果您发出:
lsb_release -i -r
Or
或者
uname -r
And map the output. 2.6.9 kernels are RHEL4, 2.6.18 kernels are RHEL5. If necessary, you can map the full version to the specific update releases from Red Hat (i.e. 2.6.9-89 is RHEL5 U4).
并映射输出。2.6.9 内核是 RHEL4,2.6.18 内核是 RHEL5。如有必要,您可以将完整版本映射到 Red Hat 的特定更新版本(即 2.6.9-89 是 RHEL5 U4)。
回答by Oz Bar-Shalom
The most simple command is:
最简单的命令是:
lsb_release -d
回答by andreiS
A trick working on numerous Linux distributions:
在众多 Linux 发行版上工作的技巧:
cat /etc/issue
Example on Red Hat 6:
Red Hat 6 上的示例:
$ cat /etc/issue
CentOS release 6.7 (Final)
Kernel \r on an \m
$
回答by VonC
Note: since July 2012, /etc/os-release
should be the standard file where to look for the version of any OS.
注意:自 2012 年 7 月以来,/etc/os-release
应该是查找任何操作系统版本的标准文件。
- It relieves application developers who just want to know the distribution they are running on to check for a multitude of individual release files.
- It provides both a "pretty" name (i.e. one to show to the user), and machine parsable version/OS identifiers (i.e. for use in build systems).
- It is extensible, can easily learn new fields if needed.
- 它减轻了那些只想知道他们正在运行的发行版以检查大量单独发布文件的应用程序开发人员的负担。
- 它提供了一个“漂亮”的名称(即向用户显示的名称)和机器可解析的版本/操作系统标识符(即用于构建系统)。
- 它是可扩展的,如果需要,可以轻松学习新领域。
See its man page.
请参阅其手册页。
# cat /etc/os-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.0 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.0"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.0 (Maipo)"
回答by ethicalthinker
try
尝试
uname -r
or
或者
cat /etc/issue
for recent linux machines
对于最近的 linux 机器
lsb_release -d
回答by Scottie H
For folks who are reading this today, or in the future:
The kernel version that is RUNNING is your version of RedHat. There may be other versions installed, but not running.
Thus, if RedHat 5.1, 5.2 & 5.x are installed on the machine, only 1 can be running at a time. This is the version that was booted at system start uop.To determine which version is actually running, use the uname
command:uname -r
This returns the Kernel release number.
For RedHat 5, it will be 2.6.18-[something]
RH 5.1 is 2.6.18-53
RH 5.2 is 2.6.18-92
To translate kernel release numbers into Redhat Version numbers, see this link:
Red Hat Enterprise Linux Release Dates
对于今天或将来正在阅读本文的人们:
正在运行的内核版本是您的 RedHat 版本。可能安装了其他版本,但没有运行。
因此,如果机器上安装了 RedHat 5.1、5.2 和 5.x,一次只能运行 1 个。这是在系统启动 uop 时启动的版本。要确定实际运行的是哪个版本,请使用以下uname
命令:uname -r
这将返回内核版本号。对于 RedHat 5,它将是 2.6.18-[something]
RH 5.1 is 2.6.18-53
RH 5.2 is 2.6.18-92
要将内核版本号转换为 Redhat 版本号,请参阅此链接:
Red Hat Enterprise Linux Release Dates