Узнать версию линукс через терминал

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?

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.

Читайте также:  Astra linux расширенное администрирование обучение

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.

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

Читайте также:  Xbox one x линукс

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

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

Когда мы говорим о Linux, то обычно подразумеваем какой-либо дистрибутив Linux. Также под Linux мы можем иметь ввиду ядро Linux.

Иногда требуется определить версию Linux, в которой вы работаете. Пользователь может не знать или забыть, какая версия дистрибутива или какая версия ядра Linux используется. Если это чужая система, то может потребоваться узнать название используемого дистрибутива.

В данной статье рассматриваются различные способы, которые помогут нам определить используемую версию Linux. Рассматривается несколько команд для определения версии Linux. Приведенные команды универсальны и не зависят от дистрибутива. Возможно, некоторые из них могут не работать в каких-то дистрибутивах, в таком случае переходите к следующей команде и пробуйте ее.

Команда lsb_release

Команда lsb_release выводит информацию о дистрибутиве.

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

Чтобы отобразить информацию о дистрибутиве выполните команду:

lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.10 Release: 18.10 Codename: cosmic

Выводится название дистрибутива, номер версии и кодовое имя.

lsb-release a команда Linux

Можно использовать опцию -d , чтобы показать только строку Description, которая обычно содержит и название и версию дистрибутива.

lsb_release -d Description: Ubuntu 18.10

Команда hostnamectl

Команда hostnamectl , выполненная без параметров или с ключом status , выводит текущую информацию о системе.

hostnamectl Static hostname: p Icon name: computer-desktop Chassis: desktop Machine ID: abc231434aabcb. a Boot ID: 51dcaa2321bbbb. a Operating System: Ubuntu 18.10 Kernel: Linux 4.18.0-16-generic Architecture: x86-64

Помимо данных дистрибутива, выводится версия ядра и архитектура.

Читайте также:  Windows linux управление памятью

hostnamectl команда Linux - информация о системе

Команда uname — версия ядра

Команда uname выводит информацию о текущем ядре системы Linux, а также некоторые дополнительные данные.

Чтобы вывести всю информацию, используется ключ -a

uname -a Linux p 4.18.0-16-generic #17-Ubuntu SMP Fri Feb 8 00:06:57 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Для удобства можно выводить только название ядра ( -s ) , версию ядра ( -r ) и архитектуру ( -m )

uname -srm Linux 4.18.0-16-generic x86_64

Команда uname. Версия ядра Linux

Файл /etc/os-release

В файле /etc/os-release содержится информация о дистрибутиве, включая URL-адреса сайт системы и некоторые дополнительные данные. Данный файл присутствует в дистрибутивах, использующих systemd.

Чтобы вывести содержимое файла /etc/os-release можно воспользоваться командой cat:

cat /etc/os-release NAME="Ubuntu" VERSION="18.10 (Cosmic Cuttlefish)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.10" VERSION_ID="18.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=cosmic UBUNTU_CODENAME=cosmic

cat /etc/os-release

Файл /etc/issue

Файл /etc/issue содержит текст, который выводится в качестве приглашения ко входу в систему. Обычно текст представляет собой название дистрибутива и версию.

Выведем содержимое файла /etc/issue командой cat:

cat /etc/issue Ubuntu 18.10 \n \l

cat /etc/issue Linux

Файлы /etc/***release и /etc/***version

Если вы используете старый или какой-то специфический дистрибутив Linux, то информация о системе может хранится в файле /etc/abc-release или /etc/abc-version .

Вместо abc обычно указывается краткий идентификатор дистрибутива или lsb, если система совместима со стандартами LSB. Вместо символа — может быть символ _ . Например, для дистрибутива Fedora используется файл /etc/fedora-release

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

echo /etc/*_ver* /etc/*-rel*; cat /etc/*_ver* /etc/*-rel* /etc/debian_version /etc/lsb-release /etc/os-release buster/sid DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.10 DISTRIB_CODENAME=cosmic DISTRIB_DESCRIPTION="Ubuntu 18.10" NAME="Ubuntu" VERSION="18.10 (Cosmic Cuttlefish)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.10" VERSION_ID="18.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=cosmic UBUNTU_CODENAME=cosmic

/etc/release /etc/version файлы Linux

Файл /proc/version

Информацию о ядре Linux также можно получить из файла /proc/version

cat /proc/version Linux version 4.18.0-16-generic (buildd@lcy01-amd64-022) (gcc version 8.2.0 (Ubuntu 8.2.0-7ubuntu1)) #17-Ubuntu SMP Fri Feb 8 00:06:57 UTC 2019

/proc/version

Через графические утилиты

Сведения о системе Linux

Многие дистрибутивы позволяют просмотреть некоторую информацию о системе, используя графические утилиты. Например, в Ubuntu это можно сделать из утилиты Параметров системы, на вкладке Сведения о системе .

Заключение

Мы рассмотрели различные способы получения информации о дистрибутиве и ядре системы Linux. Какие-то способы могут не работать в некоторых дистрибутивах Linux.

Источник

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