Linux operating system and version

Как узнать версию Linux

Когда вы сами устанавливали систему и все настраивали, то точно знаете какой дистрибутив у вас установлен, какая версия и какая версия ядра. Но совсем другая ситуация, когда вы покупаете VPS или пытаетесь настроить компьютер другу или знакомому с Linux. Довольно часто может возникнуть вопрос как узнать версию Linux потому что эта информация часто очень важна. Например, уязвимости в программном обеспечении часто затрагивают только определенные релизы.

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

Скользящие или фиксированные релизы

Все активные дистрибутивы Linux выпускают новые релизы, только все по-разному. Конечно, дистрибутивы обновляются и между релизами, но пользователям привычен такой порядок, что обновления релиза получают только исправления безопасности и ошибок, а все новые возможности выпускаются новым релизом. Но существуют и другие пути. Сейчас есть два способа выпуска релизов:

Эти способы работают немного по-разному и вам нужно понимать это прежде чем мы перейдем к версии Linux. Скользящие релизы не имеют точек выпуска нового релиза, новые возможности, исправления и улучшения постоянно добавляются в официальный репозиторий и их получают пользователи. Такой подход используется в ArchLinux, Gentoo и OpenSUSE Thumbleweed. Поэтому у таких дистрибутивов нет версий, они всегда имеют самую новую версию после того, как было выполнено обновление пакетов. Но у них есть минус — это более низкая стабильность по сравнению с фиксированными релизами, которые можно хорошо протестировать.

Фиксированные релизы используются в Ubuntu. Каждые 6 месяцев выходит новый релиз, поэтому тут есть четкое разделение на версии, новая версия дистрибутива Linux получает новое программное обеспечение, а затем на протяжении всего термина поддержки получает обновления безопасности.

Как узнать версию Linux?

На самом деле для этого есть очень много методов, начиная от общих признаков и до открыть файл и точно посмотреть версию и имя дистрибутива. Рассмотрим только самые популярные из них.

Узнать дистрибутив

Прежде всего давайте узнаем имя дистрибутива и его версию если это возможно. Для этого будем смотреть содержимое файлов в папке /etc/, которые заканчиваются на release:

В Ubuntu утилита выведет содержимое двух файлов /etc/lsb-release и /etc/os-release. В них будет содержаться исчерпывающая информация о имени дистрибутива и версии его релиза:

Но если мы выполним ту же команду в ArchLinux то получим совсем другой результат:

Читайте также:  Linux screen running process

Тут уже нет версии, есть только имя дистрибутива, поскольку ArchLinux использует систему скользящих релизов. Немного меньше, но почти всю ту же информацию можно получить используя команду lsb_release:

Также очень часто вы можете узнать имя дистрибутива посмотрев пункт «О программе» для любого системного приложения или лучше утилиты «Настройки»:

И еще один способ увидеть версию дистрибутива в основанных на Debian системах — посмотреть информацию о сборке пакета:

Узнать версию ядра

Во многих случаях нам нужна не столько версия дистрибутива linux, сколько версия ядра, которое в нем используется. Для просмотра этой информации тоже есть несколько команд:

У меня используется версия ядра 4.8.0-59, тут же мы видим архитектуру системы — x86_64. Обозначение SMB означает, что ядро поддерживает многоядерные процессоры или несколько процессоров. Но мы можем узнать ту же информацию, посмотрев содержимое файла /proc/version:

А еще можно посмотреть строку параметров запуска ядра, она тоже содержит версию:

Есть еще несколько файлов с подобной информацией:

Как узнать архитектуру компьютера

Вы уже знаете как узнать версию Linux, имя дистрибутива и ядро, архитектура уже проскальзывала в командах выше, но существует отдельная команда, которая выводит только архитектуру:

Для этих же целей можно использовать uname:

Выводы

Теперь вы знаете как посмотреть версию Linux. Как видите, в Linux достаточно много способов для решения этой задачи. Надеюсь, эта информация была полезной для вас.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

How To Find Linux OS Distribution and Version?

How To Find Linux OS Distribution and Version?

Linux is a free and open-source operating system. A lot of distributions and versions are created on the Linux kernel. Even all of them are called Linux they have specific names and versions like Ubuntu 20.04, Debian 11, RHEL 8, etc. While working with Linux knowing the distributions and version is very important. Especially while using the command line or bash shell the commands and configuration supported current Linux is important. In this tutorial, we will learn how to list or display current Linux distributions, version, and Linux kernel version.

List Distribution and Versions with lsb_release Command

The lsb_release is a very popular command which is provided by most Linux distributions. The lsb_release command can be used in Ubuntu, Debian, Mint, Kali, Fedora, CentOS, Rocky Linux, RHEL, SUSE etc. The -a option should be provided to the lsb_release command in order to list current distribution name and version.

The output is like below which contains distribution ID, description, release number which can be also called as version and the codename. Codename is used by some Linux distributions in order to name different versions. We can see that current distributions name is “Ubuntu” and version is “20.10”.

Distributor ID: Ubuntu Description: Ubuntu 20.10 Release: 20.10 Codename: groovy

List Distribution and Versions with /etc/os-release File

Some linux distirbutions like Debian, Ubuntu stores the current distributions name and version information in the file named “/etc/os-release”. This file contains detailed information which can be printed to the terminal by using the cat command like below.

Читайте также:  Time in linux cli

We can see that following information about the distributions and version is provided.

  • NAME: The distributions name which is “Ubuntu” in this example.
  • VERSION: The version of the distribution which is 20.10 in this example.
  • ID: The distribution canonical name which is “ubuntu” in this example.
  • ID_LIKE: The distribution source where “debian” is the source of the Ubuntu.
  • PRETTY_NAME: The distribution human friendly complete name with the distribution name and version.
  • VERSION_ID: The distribution version which is “20.10”.
  • HOME_URL: The distribution official web site URL which is “https://www.ubuntu.com/” in this case.
  • VERSION_CODENAME: This is version code name which is “groovy” in this example.
  • UBUNTU_CODENAME: This is ubuntu version code name which is “groovy” in this example.
NAME="Ubuntu" VERSION="20.10 (Groovy Gorilla)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.10" VERSION_ID="20.10" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=groovy UBUNTU_CODENAME=groovy

If we need to list only the Linux os name and version the grep command can be used to filter the output like below.

grep "^PRETTY_NAME" /etc/os-release

If we want only list the operating system name the following command can be used.

Only distribution version can be printed by grepping the VERSION_ID line like below.

grep "^VERSION_ID" /etc/os-release

Alternatively a text editor can be used to view the current Linux os distribution name and version via the desktop environment.

List Distribution and Versions with hostnamectl Command

The hostnamectl command is used to manage, list, change the hostname and related information. but it can be also used to list the Linux OS name with the version information. Just run the hostnamectl command which will list the Operating System line with the distribution name and version. Also the Kernel line provides the currently installed and running kernel version.

Static hostname: ubuntu Icon name: computer-vm Chassis: vm Machine ID: 295c2cf105a140e5ab505a9e74ff560e Boot ID: ac4b559e8d414569816cd76c3e330727 Virtualization: vmware Operating System: Ubuntu 20.10 Kernel: Linux 5.8.0-45-generic Architecture: x86-64

If you just want to list distribution name and version the grep command can be used filter the “Operating System:” line like below.

hostnamectl | grep "Operating System" 
Operating System: Ubuntu 20.10

List Distribution and Versions with uname Command

The uname command can be also used to list Linux distribution OS names. The -a option should be provided to list all information about the system. This command does not provide the distribution version but lists the kernel version.

Linux ubuntu 5.8.0-45-generic #51-Ubuntu SMP Fri Feb 19 13:24:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

List Distribution and Versions with /proc/version File

The /proc/ directory contains information about the system and low level operations and functions. The /proc/version can be used to list current distribution name but the version information is not provided.

Linux version 5.8.0-45-generic (buildd@lcy01-amd64-010) (gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0, GNU ld (GNU Binutils for Ubuntu) 2.35.1) #51-Ubuntu SMP Fri Feb 19 13:24:51 UTC 2021

List Distribution and Versions with /etc/issue File

The /etc/issue file only contains the current Linux distribution name and version. This is very simple file and can be listed with the cat command.

Читайте также:  Install archive on linux

List Distribution and Versions by Connection SSH

Even this is not a practical way to display the current Linux distribution name and version it can be used for different cases. When we login to the Linux system with the SSH protocol the current distribution name and version are listed below. In the following example, the Linux OS name is Ubuntu and the version is 20.10.

Источник

How do I find out what version of Linux I’m running?

Is there a way to determine what version (distribution & kernel version, I suppose) of Linux is running (from the command-line), that works on any Linux system?

I’d just like to point out for the record how stupid it is that this is a question which needs asking. This is really quite an indictment on the state of every linux distro.

9 Answers 9

The kernel is universally detected with uname :

$ uname -or 2.6.18-128.el5 GNU/Linux 

There really isn’t a cross-distribution way to determine what distribution and version you’re on. There have been attempts to make this consistent, but ultimately it varies, unfortunately. LSB tools provide this information, but ironically aren’t installed by default everywhere. Example on an Ubuntu 9.04 system with the lsb-release package installed:

$ lsb_release -irc Distributor ID: Ubuntu Release: 9.04 Codename: jaunty 

Otherwise, the closest widely-available method is checking /etc/something-release files. These exist on most of the common platforms, and on their derivatives (i.e., Red Hat and CentOS).

$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=9.04 DISTRIB_CODENAME=jaunty DISTRIB_DESCRIPTION="Ubuntu 9.04" 

But Debian has /etc/debian_version :

$ cat /etc/debian_version 5.0.2 

Fedora, Red Hat and CentOS have:

Fedora: $ cat /etc/fedora-release Fedora release 10 (Cambridge) Red Hat/older CentOS: $ cat /etc/redhat-release CentOS release 5.3 (Final) newer CentOS: $ cat /etc/centos-release CentOS Linux release 7.1.1503 (Core) 
$ cat /etc/gentoo-release Gentoo Base System release 1.12.11.1 

I don’t have a SUSE system available at the moment, but I believe it is /etc/SuSE-release .

Slackware has /etc/slackware-release and/or /etc/slackware-version .

Mandriva has /etc/mandriva-release .

For most of the popular distributions then,

will most often work. Stripped down and barebones «server» installations might not have the ‘release’ package for the distribution installed.

Additionally, two 3rd party programs you can use to automatically get this information are Ohai and Facter.

Note that many distributions have this kind of information in /etc/issue or /etc/motd , but some security policies and best practices indicate that these files should contain access notification banners.

Источник

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