Command linux operating system version

How to check os version in Linux command line

Check os version in Linux

The procedure to find os name and version on Linux:

  1. Open the terminal application (bash shell)
  2. For remote server login using the ssh: ssh user@server-name
  3. Type any one of the following command to find os name and version in Linux:
    cat /etc/os-release
    lsb_release -a
    hostnamectl
  4. Type the following command to find Linux kernel version:
    uname -r

Let us see all examples in details for common Linux distros.

The /etc/os-release file

Type the following cat command:
$ cat /etc/os-release
Sample outputs:

We can filter out information such as OS version and name using the grep command/egrep command as follows:
$ grep ‘^VERSION’ /etc/os-release
$ egrep ‘^(VERSION|NAME)=’ /etc/os-release
Here is what we see:

Even tiny Linux distro such as Alpine Linux provide the required OS (Operating system) information, including version:

Checking OS version on Linux using the lsb_release command

The lsb_release command gives LSB (Linux Standard Base) and distribution-specific information on the CLI. The syntax is:
$ lsb_release -a
Sample outputs:

hostnamectl command

Use hostnamectl command to query and change the system hostname and related settings. Just type the following command to check OS name and Linux kernel version:
$ hostnamectl
And it will give info as follows. Look out for “ Operating System ” and “ Kernel “:

Another outputs from my OpenSUSE Linux 15.2 server:

uname command

/etc/issue file

Use more command/less command as follows:
$ cat /etc/issue
$ more /etc/issue
$ less /etc/issue

Getting help

You can also view the manual page on uname using the following command:
$ man hostnamectl
$ man uname
$ man cat

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard
Читайте также:  Get file time windows

Join Patreon

Conclusion

We explained how to find and display the OS version on Linux. The safest option is to query /etc/os-release file using grep or cat command. Systemd based Linux distro users can use the hostnamectl command.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

How to Check OS Version in Linux

Linux version can be checked using inbuilt commands or can read from specific files. It is important to determine the distribution name and version on many occasion like when doing package updates or OS update.

There are a lot of Linux distributions available like Debian, Ubuntu, CentOS, Mint, Arch, Fedora, RHEL, and more.

In this tutorial, I will show how to check the Linux version from the command line.

Check Linux Version

There are mainly 5 ways we can get Linux distribution name and its version.

1. From /etc/os-release

Use cat command to read the content of the file /etc/os-release , run the following command:

Output from CentOS

Output from Ubuntu

2. Using lsb_release command

The lsb_release -a displays the Linux version information from the command line. The output will display distribution ID, description, release and codename. To display only the description you can use lsb_release -d .

If you get «command not found» and then you need to install ‘lsb-core’ package.

Output of lsb_release -a

To display only the description, run:

3. Using Hostnamectl command

In modern Linux distributions which use systemd init systems, you can use hostnamectl command to display operating system version.

4. From /etc/issue file

You can get version information from /etc/issue file, to read file content use cat or less command:

5. From /etc/*release or /etc/*version

Some distribution use release and version file and those files are specific to that distro.

$ echo /etc/*version /etc/*release
/etc/debian_version /etc/ec2_version /etc/lsb-release /etc/os-release

To read the content from /etc/*release or /etc/*version, run the following command:

If you are interested to know the Linux kernel version and architecture then use uname command or you can read the content from /proc/version file.

Conclusion

In this tutorial, we learned different ways to find Linux OS name and version from I hope you enjoyed reading and please leave your suggestion in the below comment section.

Источник

Как узнать версию Linux (+ информацию о железе, хар-ки ПК)

Всех приветствую!

В тему: «В гостях, конечно, хорошо, но дома лучше. «.

Когда работаешь за своим ПК — обычно всё о нем знаешь (и железки, и ПО (и все царапины на корпусе 😉)). Но при знакомстве с «неизвестной машиной» — порой, требуется узнать о ней больше: характеристики, версию дистрибутива и ядра Linux.

В принципе, сделать это несложно: 1-2 команды (если не брать отдельные исключительные случаи. ).

Читайте также:  Fatality hardware corrupted page windows 10

Собственно, ниже я и собираюсь привести пару способов, которые «расскажут» нам о текущей ОС (отмечу, что приведенные команды универсальны и работают в разных дистрибутивах).

Примечание : я исхожу из того, что ОС у вас запущена и вы можете вызвать терминал (Ctrl+Alt+T или Win+T). Если какая-то команда ниже у вас не сработает — попробуйте следующую.

Несколько вариантов узнать информацию о текущей ОС Linux

👉 Вариант 1: вкладка «About»

В большинстве дистрибутивах Linux (особенно для начинающих) узнать информацию о системе можно вообще без всяких команд: достаточно открыть параметры системы и перейти во вкладку «About» . 👇

POP!_OS — скрин из панели управления, вкладка About

Кстати, обратите внимание, что через вкладку «About» можно узнать не только о ОС, но и о железках на ПК: процессор, ОЗУ, видеокарта и пр.

Elementary OS — вкладка About

Информация о ОС

👉 Вариант 2

Команда lsb_release -a выведет название дистрибутива, его ID, номер версии (релиза), и кодовое название. Как правило, работает в большинстве дистрибутивах!

  1. Distributor ID: Pop
  2. Description: Pop!_OS 20.10
  3. Release: 20.10
  4. Codename: groovy

👉 Вариант 3

Команда hostnamectl позволяет вывести на экран базовые сведения о текущей версии ОС (обратите внимание на строчку «Operating System» 👇).

hostnamectl (Elementary OS)

Пример (в тексте из Linux Mint):

$ hostnamectl
Static hostname: mint
Icon name: computer-laptop
Chassis: laptop
Machine ID: 939972095cf1459c8b22cc608eff85da
Boot ID: cc35e48fabd4460fb94d7102965ce576
Operating System: Linux Mint 20.1
Kernel: Linux 5.4.0-58-generic
Architecture: x86-64

👉 Вариант 4

Этот вариант помимо ОС, расскажет о многих железках на ПК. Наиболее информативный способ!

Попробуйте в терминале ввести команду inxi -F и нажать Enter.

Если появиться ошибка — тогда введите sudo apt install inxi и нажмите Enter. Когда установка пакета будет завершена — снова используйте команду inxi -F .

Пример (Linux Mint):

$ inxi -F
System:
Host: mint Kernel: 5.4.0-58-generic x86_64 bits: 64
Desktop: Cinnamon 4.8.5 Distro: Linux Mint 20.1 Ulyssa
Machine:
Type: Laptop System: ASUSTeK product: UX310UAK v: 1.0
serial:
Mobo: ASUSTeK model: UX310UAK v: 1.0 serial:
UEFI: American Megatrends v: UX310UAK.306 date: 08/09/2017
Battery:
ID-1: BAT0 charge: 19.9 Wh condition: 41.2/48.3 Wh (85%)
CPU:
Topology: Dual Core model: Intel Core i5-7200U bits: 64 type: MT MCP
L2 cache: 3072 KiB
Speed: 500 MHz min/max: 400/3100 MHz Core speeds (MHz): 1: 500 2: 500
3: 500 4: 501
Graphics:
Device-1: Intel HD Graphics 620 driver: i915 v: kernel
Display: x11 server: X.Org 1.20.8 driver: modesetting unloaded: fbdev,vesa
resolution: 1920×1080

60Hz
OpenGL: renderer: Mesa Intel HD Graphics 620 (KBL GT2) v: 4.6 Mesa 20.0.8
Audio:
Device-1: Intel Sunrise Point-LP HD Audio driver: snd_hda_intel
Sound Server: ALSA v: k5.4.0-58-generic
Network:
Device-1: Intel Wireless 8260 driver: iwlwifi
IF: wlp2s0 state: up mac: 90:61:ae:46:f1:2c
Drives:
Local Storage: total: 581.02 GiB used: 840.5 MiB (0.1%)
ID-1: /dev/sda vendor: Crucial model: CT480BX500SSD1 size: 447.13 GiB
ID-2: /dev/sdb model: SSD 128GB size: 119.24 GiB
ID-3: /dev/sdc type: USB vendor: Innostor model: Innostor size: 14.65 GiB
Partition:
ID-1: / size: 5.79 GiB used: 840.5 MiB (14.2%) fs: overlay source: ERR-102
Sensors:
System Temperatures: cpu: 36.0 C mobo: N/A
Fan Speeds (RPM): cpu: 3100
Info:
Processes: 236 Uptime: 13m Memory: 11.59 GiB used: 1.22 GiB (10.5%)
Shell: bash inxi: 3.0.38

Читайте также:  Нет русской кодировки при установке windows

👉 Вариант 5

В одном из файлов (/etc/os-release) ОС есть информация о дистрибутиве. Для его просмотра достаточно в терминале использовать команду cat /etc/os-release .

Есть еще один файл с информацией о системе (/etc/issue) — он используется при приглашении войти в систему. Для вывода информации из него — используйте cat /etc/issue .

Информация о ядре доступна в файле: /proc/version (команда cat /proc/version ).

Пример (Linux Mint):

$ cat /etc/os-release
NAME=»Linux Mint»
VERSION=»20.1 (Ulyssa)»
>
ID_LIKE=ubuntu
PRETTY_NAME=»Linux Mint 20.1″
VERSION_ID=»20.1″
HOME_URL=»https://www.linuxmint.com/»
SUPPORT_URL=»https://forums.linuxmint.com/»
BUG_REPORT_URL=»http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/»
PRIVACY_POLICY_URL=»https://www.linuxmint.com/»
VERSION_CODENAME=ulyssa
UBUNTU_CODENAME=focal
mint@mint:

👉 Вариант 6

Чтобы узнать версию ядра Linux (и доп. сведения о архитекторе), можно воспользоваться утилитой uname, парочка команд в помощь:

Пример (Linux Mint):

$ uname -r
5.4.0-58-generic
mint@mint:

$ uname -a
Linux mint 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Источник

◾ Как узнать версию Linux из командной строки

Вступление

Как узнать, с каким дистрибутивом и с какой версией дистрибутива вы работаете?

Это жизненно важный вопрос.

Во-первых, вы можете подумать о наборе uname -a, но это не дает всей необходимой вам информации.

К счастью, есть файл, который есть почти во всех дистрибутивах, в котором хранятся эти ценные данные.

Это файл /etc/os-release.

Вы можете догадаться, как его можно просмотреть, потому что мы уже рассмотрели использование команды cat.

Итак, вы просто делаете следующее, и у вас всегда будет то, что вы ищете.

С другой стороны, uname предоставляет следующую системную информацию:

  • -a, –all вывести всю информацию в следующем порядке, за исключением опущенных -p и -i, если неизвестно:
  • -s, –kernel-name вывести имя ядра
  • -n, –nodename вывести имя узла сети
  • -r, –kernel-release вывести выпуск ядра
  • -v, –kernel-version вывести версию ядра
  • -m, –machine Вывести название оборудования машины
  • -p, –processor вывести тип процессора (не переносимый)
  • -i, –hardware-platform вывести аппаратную платформу (непереносную)
  • –Version вывести uname информацию о версии и выйти
  • -o, -operating-system (в основном выводит GNU / Linux)

Примеры использования uname

Как вы можете видеть выше, дистрибутив и версию дистрибутива невозможно найти с помощью команды uname.

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

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

Смотрите примеры использования ниже.

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

Для систем Linux с Systemd init вы можете получить некоторую системную информацию из вывода команды hostnamectl, например,

«Операционная система, версия ядра и архитектура ЦП».

Посмотрите полный список доступных опций:

Проверьте содержимое файла /etc/issue

Просмотр содержимого /etc/issue.

Заключение

Найти дистрибутив и версию дистрибутива очень просто, как вы узнали.

Мы надеемся, что это было полезно и информативно.

Источник

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