Посмотреть какая версия linux

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.

Источник

How can I tell what version of Linux I’m using?

Often times I will ssh into a new client’s box to make changes to their website configuration without knowing much about the server configuration. I have seen a few ways to get information about the system you’re using, but are there some standard commands to tell me what version of Unix/Linux I’m on and basic system information (like if it is a 64-bit system or not), and that sort of thing? Basically, if you just logged into a box and didn’t know anything about it, what things would you check out and what commands would you use to do it?

Читайте также:  Sangoma linux настройка сети

13 Answers 13

If I need to know what it is say Linux/Unix , 32/64 bit

This would give me almost all information that I need,

If I further need to know what release it is say (Centos 5.4, or 5.5 or 5.6) on a Linux box I would further check the file /etc/issue to see its release info ( or for Debian / Ubuntu /etc/lsb-release )

Alternative way is to use the lsb_release utility:

Or do a rpm -qa | grep centos-release or redhat-release for RHEL derived systems

In 2016 it does not seem like lsb_release works any longer with modern distros. I tested the command on Amazon Linux AMI release 2016.03 and CentOS Linux 7 and it was not found. It seems like ls cat /etc/os-release is the best solution currently with uname -a somewhat usable if a bit opaque (e.g. Amazon Linux AMI release 2016.03 vs. Linux ip-x-x-x-x 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux)

Use the following commands to get more details:

Add cat /proc/version and it covers every release I’ve found over the years. I’ve never seen a case where /proc/version wasn’t helpful, but I’ve seen cases where one or both of the above don’t help (can’t remember which but most likely embedded systems.)

There are a ton of answers but I’m looking for more generic. AFAI am concerned the following works on most of systems.

sh-4.4$ cat /etc/os-release NAME=Fedora VERSION="26 (Twenty Six)" ID=fedora VERSION_ID=26 PRETTY_NAME="Fedora 26 (Twenty Six)" ANSI_COLOR="0;34" CPE_NAME="cpe:/o:fedoraproject:fedora:26" HOME_URL="https://fedoraproject.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=26 REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=26 PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy 

This will work on Linux distros that use systemd. For older versions of those distros that don’t use systemd, this won’t work (e.g. RHEL 6), and for distros that don’t use systemd at all this won’t work. The second most voted answer will cat this file anyway, so there’s no reason not to prefer that more general command.

Linux version 3.14.27-100.fc19.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC) ) #1 SMP Wed Dec 17 19:36:34 UTC 2014 

I believe this works for most distros, and provides a more concise answer than cat /etc/*release* and more complete answer than uname -a . However, use of /proc for things other than processes is now eschewed, so maybe it’ll disappear someday.

On Apline 3.10.4 this returned something unexpected: Linux version 4.19.76-linuxkit (root@d203b39a3d78) (gcc version 8.3.0 (Alpine 8.3.0)) #1 SMP Thu Oct 17 19:31:58 UTC 2019

@b01 Thanks for the input. At least it got the Alpine part correct. 😉 Where did 3.10.4 come from, uname -a ? It’s sad that there is no single correct answer!

I learned this while writing a tool that did a survey of connected systems which were embedded Linux running on various brands and models of storage servers. It was the only command I found that returned something useful in every case, and since then I’ve never seen it not be useful, even on BusyBox-based distros.

Читайте также:  Unknown error cannot find chrome binary linux

@JeffLearman I was using a Go Lang Alpine Docker image of 1.13-alpine-3.10 and wanted to know the bug release number. I ended up trying quite a few of these answers to see which worked and not.

You should look into the uname command.

I have to deal with a large parc of heterogenous machines. uname -a is usually my first reflex when I log in.

For the Alpine distribution:

To combine some ideas here:

cat /etc/*_version /etc/*-release && uname -a

Should get you want you need on any distribution.

To those who are searching for which version is alpine running inside docker, this command works and produces following output: cat: can’t open ‘/etc/*_version’: No such file or directory 3.14.2 NAME=»Alpine Linux» VERSION_ID=3.14.2 PRETTY_NAME=»Alpine Linux v3.14″ HOME_URL=»https://alpinelinux.org/» BUG_REPORT_URL=»https://bugs.alpinelinux.org/»

That’ll give you all the information you seek.

man uname to restrict the information

inxi is a System Information Tool for Linux. It displays handy information concerning system hardware (hard disk, sound cards, graphic card, network cards, CPU, RAM, and more), together with system information about drivers, Xorg, desktop environment, kernel, GCC version(s), processes, uptime, memory, and a wide array of other useful information.

If inxi is not installed in your system, you can install it by:

$ sudo apt install inxi [On Debian/Ubuntu/Linux Mint] $ sudo yum install inxi [On CentOs/RHEL/Fedora] $ sudo dnf install inxi [On Fedora 22+] 

In manpage you can fine that -S option can be used to get host name, kernel, desktop environment (if in X/Wayland), distro.

% inxi -S System: Host: blueray-i5 Kernel: 5.4.0-53-generic x86_64 bits: 64 Desktop: Cinnamon 4.6.7 Distro: Linux Mint 20 Ulyana 

This can be used as a debugging, and/or forum technical support tool. So you might consider keeping it in your toolbelt.

Источник

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

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

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

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

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

Читайте также:  Comodo internet security linux

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Выводы

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

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

Источник

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