Red hat linux посмотреть версию

What version of RHEL am I using?

From the shell and without root privileges, how can I determine what Red Hat Enterprise Linux version I’m running? Ideally, I’d like to get both the major and minor release version, for example RHEL 4.0 or RHEL 5.1, etc.

9 Answers 9

You can use the lsb_release command on various Linux distributions:

This will tell you the Distribution and Version and is a little bit more accurate than accessing files that may or may not have been modified by the admin or a software package. As well as working across multiple distros.

lsb_release -i -r -bash: lsb_release: command not found. However, cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.6 (Tikanga)

Just for the record: Does not work on RHEL 6.5 minimal install. Command lsb_release is nowhere to be found.

lsb_release is not a lightweight package, It pulls in CUPS to provide ‘/usr/bin/lp’, which pulls in some pdf translation goop, which pulls in some rendering libraries.

You can look at the contents of /etc/redhat-release, which will look something like this:

$ cat /etc/redhat-release CentOS release 5.4 (Final) 

The contents are different for an actual RHEL system. This technique works on all RedHat derivatives, including CentOS, Fedora, and others.

lsb_release is the first thing to try, but since that might not be installed looking at files is a good Plan B.

@chicks Given that the question asks for a test for Redhat systems, and lsb_release is not installed by default on redhat systems and /etc/redhat-release is, then lsb_release is obviously not the first thing to try!

@bye It is the first thing to try (at least in my opinion) , you always try the things which should be common on all distributions first, then only you switch to distribution-specific solutions.

I prefer to use the /etc/issue file.

I’ve seen many situations where /etc/redhat-release has been modified to meet software compatibility requirements (Dell or HP’s management agents, for instance).

/etc/issue also works on other OSes as well, such as Debian & Ubuntu, and works with Linux OSes that don’t conform to the Linux Standards Base, and lightweight OSes that don’t have the lsb* utilities installed.

This is not reliable. Apparently /etc/issue is meant to be parsed by agetty, which replaces the escape sequences with proper information. If you just cat it, the result may be underwhelming. On Fedora, one gets Fedora release 20 (Heisenbug) Kernel \r on an \m (\l) , which tells you something but on RHEL7, one just gets \S Kernel \r on an \m .

Читайте также:  Gui для sqlite linux

Note that /etc/issue may be replaced by the local admin and hence is not a reliable source of information.

The most reliable way when lsb_release is not installed is:

# rpm -q --queryformat '%' redhat-release-server 6Server # rpm -q --queryformat '%' redhat-release-server 6.4.0.4.el6 

On minimal installs, lsb_release is missing.

To get this working also with Red Hat clones (credit goes to comments):

# rpm -q --queryformat '%' $(rpm -qa '(redhat|sl|slf|centos|oraclelinux)-release(|-server|-workstation|-client|-computenode)') 

Or, as a single command (rather than two «rpm»‘s being executed):

# rpm -qa --queryformat '%\n' '(redhat|sl|slf|centos|oraclelinux)-release(|-server|-workstation|-client|-computenode)' 

Use sed / cut and other text manipulating UNIX tools to get what you want.

This seems to work, more generically: rpm -qa ‘(oraclelinux|sl|redhat|centos)-release(|-server)’ sl is for Scientific Linux; if you know the right name for other RHEL rebuilds maybe comment below. Warning — not extensively tested.

Assuming it truly is a Red Hat release (not Centos):

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).

rpm -q redhat-release just returns package redhat-release is not installed for me, and uname -r just tells me the kernel release.

Oh ! And now that time has passed, what would be RHEL6 ? RHEL7 ? Hum. Here are the answers: access.redhat.com/articles/3078#RHEL7

$ hostnamectl Static hostname: xxxxxx.xxx.xxx Icon name: computer-server Chassis: server Machine ID: 3e3038756eaf4c5c954ec3d24f35b13f Boot ID: 958452e0088b4191a4ea676ebc90403b Operating System: Red Hat Enterprise Linux Server 7.5 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.5:GA:server Kernel: Linux 3.10.0-862.3.3.el7.x86_64 Architecture: x86-64 

I quite like using the /etc/os-release file, which is in the release RPM:

# yum whatprovides /etc/os-release Loaded plugins: fastestmirror, langpacks Determining fastest mirrors * base: dl.za.jsdaav.net * extras: dl.za.jsdaav.net * updates: dl.za.jsdaav.net centos-release-7-4.1708.el7.centos.x86_64 : CentOS Linux release file Repo : base Matched from: Filename : /etc/os-release centos-release-7-4.1708.el7.centos.x86_64 : CentOS Linux release file Repo : @anaconda Matched from: Filename : /etc/os-release 

This file can be sourced in scripts, like:

$ source /etc/os-release $ echo $NAME CentOS Linux $ echo $VERSION 7 (Core) 

If you want to just get the version numbers the following is about as short and simple as I can get it.

Tested on rhel 6.7, rhel 7.2, debian 8.3 and ubuntu 14.04:

lsb_release -s -r | cut -d '.' -f 1 

For a practical example, say you want to test for the distribution major and minor version and do things based on that:

#!/bin/bash major=$(lsb_release -s -r | cut -d '.' -f 1) minor=$(lsb_release -s -r | cut -d '.' -f 2) if (( "$major" >= 7 )) then echo "Do stuff, OS major version is $major" echo "OS minor version is $minor" else echo "Do other things" echo "Your version is $major.$minor" fi 

A late arrival to this, but I had fun trying to figure out the RHEL version on several remote nodes. So, if you have a batch of servers that use the same password (I know, I know. ) here is a quick and dirty to check the RedHat version:

Create an expect script

Expect script to check major RedHat version on multiple remote hosts

#!/usr/bin/expect log_user 0 spawn ssh -l root [lindex $argv 0] expect "assword:" send "sUp3rS3cr3tP4ssW0rd^\r" expect "# " log_user 1 send "cat /etc/redhat-release\r" expect "*#" log_user 0 send "exit\n" 

Run the script for all your nodes

[root@home ~]# for server in server1 server2 server3 server4 server5; do echo -e "$server: \c"; /root/server-version.sh $server; echo; echo; done; 
server1: cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.3 (Maipo) [root@server1 ~]# server2: cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.3 (Maipo) [root@server2 ~]# . 

Источник

Читайте также:  Linux 1с обновление конфигурации

4 способа проверить версию CentOS или RHEL

Знаете ли вы версию выпуска CentOS/RHEL, которую вы используете на своем сервере? Почему это вообще важно? Есть несколько причин помнить эту информацию: чтобы быстро собрать информацию о вашей системе; следите за исправлениями ошибок и обновлениями безопасности, а также настраивайте правильные репозитории программного обеспечения для определенного выпуска, среди прочего.

Это, вероятно, простая задача для опытных пользователей, но обычно не для новичков. В этой статье мы покажем, как проверить версию CentOS или RHEL Linux, установленных на вашем сервере.

Как проверить версию ядра Linux в CentOS

Знать версию ядра так же важно, как и версию выпуска дистрибутива. Чтобы проверить версию ядра Linux, вы можете использовать команду uname.

$ uname -or OR $ uname -a #print all system information

Судя по результату приведенной выше команды, CentOS использует старую версию ядра, чтобы установить или обновить до последней версии ядра, следуйте инструкциям в нашей статье: Как установить или обновить до ядра 4.15. в CentOS 7.

Как проверить версию выпуска CentOS или RHEL

Номера версий выпуска CentOS состоят из двух частей: основной версии, такой как \6 или \7, и дополнительной или обновленной версии, например, \6.x или \7.x, которые соответствуют основной версии и набору обновлений RHEL. , используемый для сборки определенного выпуска CentOS.

Чтобы уточнить это, возьмем, например, CentOS 7.5, созданную из исходных пакетов RHEL 7 обновление 5 (также известное как RHEL версии 7.5), которая называется точечной версией RHEL 7.

Давайте рассмотрим эти 4 полезных способа проверить версию выпуска CentOS или RHEL.

1. Использование команды RPM

RPM (Red Hat Package Manager) — популярная и основная утилита управления пакетами для систем на базе Red Hat, таких как (RHEL, CentOS и Fedora), используя эту команду rpm, вы получите версию выпуска CentOS/REHL.

$ rpm --query centos-release [On CentOS] $ rpm --query redhat-release [On RHEL] 

2. Использование команды Hostnamectl

команда hostnamectl используется для запроса и установки имени хоста системы Linux, а также для отображения другой информации, связанной с системой, такой как версия выпуска операционной системы, как показано на снимке экрана.

3. Использование команды lsb_release

Команда lsb_release отображает некоторый LSB (Стандартная база Linux) и информацию о распространении. В CentOS/REHL 7 команда lsb_release предоставляется в пакете redhat-lsb, который вы можете установить.

$ sudo yum install redhat-lsb

После того, как вы его установили, вы можете проверить свою версию CentOS/REHL, как показано ниже.

4. Использование файлов выпуска дистрибутива

Все приведенные выше команды извлекают информацию о выпуске ОС из ряда системных файлов. Вы можете просмотреть содержимое этих файлов напрямую, используя команду cat.

$ cat /etc/centos-release [On CentOS] $ cat /etc/redhat-release [On RHEL] $ cat /etc/system-release $ cat /etc/os-release #contains more information

Это пока все! Если вы знаете какой-либо другой метод, который должен быть описан здесь, сообщите нам об этом через форму комментариев ниже. Также вы можете задать любые вопросы по теме.

Читайте также:  Pacman в linux manjaro

Источник

4 Ways to Check CentOS or RHEL Version

Do you know the version of CentOS/RHEL release you are running on your server? Why is this even important? There are several reasons to keep this information in mind: to quickly gather information about your system; keep up with bug fixes and security updates, and configure correct software repositories for a specific release, among others.

This is probably an easy task for experienced users, but it’s not usually the case for newbies. In this article, we will show how to check the version of CentOS or RHEL Linux installed on your server.

How to Check Linux Kernel Version in CentOS

Knowing the kernel version is just as important as knowing the distro release version. To check Linux kernel version, you can use the uname command.

$ uname -or OR $ uname -a #print all system information

Check Kernel Version in CentOS

From the output of the above command, the CentOS is powered by an old kernel version, to install or upgrade to the latest kernel release, follow the instructions in our article: How to Install or Upgrade to Kernel 4.15 in CentOS 7.

How to Check CentOS or RHEL Release Version

CentOS release version numbers have two parts, a major version such as “6” or “7” and a minor or update version, such as or “6.x” or “7.x”, which correspond to the major version and update set of RHEL receptively, used to build a particular CentOS release.

To elaborate more in this, take for instance CentOS 7.5 is built from the source packages of RHEL 7 update 5 (also known as RHEL version 7.5), which is referred to as a “point release” of RHEL 7.

Let’s take a look at these 4 useful ways to check CentOS or RHEL release version.

1. Using RPM Command

RPM (Red Hat Package Manager) is a popular and core package management utility for Red Hat based systems like (RHEL, CentOS and Fedora), using this rpm command, you will get your CentOS/REHL release version.

$ rpm --query centos-release [On CentOS] $ rpm --query redhat-release [On RHEL] 

Check CentOS Version Using RPM Command

2. Using Hostnamectl Command

hostnamectl command is used to query and set Linux system hostname, and show other system related information, such as operating system release version as shown in the screenshot.

Check CentOS Version Using hostnamectl Command

3. Using lsb_release Command

lsb_release command displays some LSB (Linux Standard Base) and distribution information. On CentOS/REHL 7, the lsb_release command is provided in the redhat-lsb package which you can install it.

$ sudo yum install redhat-lsb

Once you have installed it, you can check your CentOS/REHL version as shown.

Show CentOS Version

4. Using Distro Release Files

All the above commands retrieve OS release information from a number of system files. You can view the contents of these files directly, using the cat command.

$ cat /etc/centos-release [On CentOS] $ cat /etc/redhat-release [On RHEL] $ cat /etc/system-release $ cat /etc/os-release #contains more information

Check CentOS Release Version

That’s all for now! If you know any other method that should be covered here, let us know via the comment form below. You can also ask any questions related to the topic.

Источник

Оцените статью
Adblock
detector