Linux display operating system

Which Command Is Used To Display The Operating System?

To know the name of the operating system, open the terminal using Ctrl+Alt+T or by selecting it from the application menu.

Now, in the terminal window, use any of the following commands to know the name of your operating system:

Command 1: Just the name of the operating system

Here you can see the name of the operating system («Ubuntu») along with the processor architecture present on which the OS is running, that is x86_64. The output also shows the timestamp as to when the command was executed.

There are a few variations of this command:

Command 2: Getting just the kernel version

More flags for this uname command can be found using the following command:

Some other commands that can be used to display the name of the operating system in Linux are:

The cat command is used to display the contents of any file that is given as arguement. Here, the file /etc/os-release contains all this information, which is presented in the terminal window.

Please note that it is possible that lsb_release might not be installed on your Linux system by default. Hence, to use this command, install lsb_release prior to using it.

Please note that Machine ID and Boot ID are hidden for security purposes in the above output, but they will be displayed on your command line.

b. Windows operating system

To display the name of the operating system, open the command prompt and enter the following command:

This command will give multiple lines of output in the command prompt. Only two of those lines (2nd and 3rd line) are important for us right now:

c. UNIX / macOS

Since macOS is built upon UNIX, the same command will work on both the systems.

Use the following commands in the terminal:

Darwin here refers to the base kernel used by macOS.

Learn More About Operating Systems

Read article to learn more about operating systems. What is Operating System?

Conclusion

The commands used to display the name of operating system on:

  1. Linux based OS:
    • uname -a
    • uname -r
    • cat /etc/os-release
    • lsb_release -a
    • hostnamectl
  2. Windows:
    • systeminfo
  3. macOS/UNIX:
    • uname -a
    • sw_vers

Источник

How to Find Which Linux Version You Are Running

Logged in on a Linux system via SSH and wondering which Linux distribution is it? Here’s how to check the Linux version.

Читайте также:  Huge pages linux oracle

When you install a Linux distribution on your own, you know which distribution and version it is.

But if you use SSH to log in to a remote Linux server provided by an enterprise or client, you may wonder which Linux distribution and version it is.

The simplest way to check Linux version is to see the content of the /etc/os-release file:

It will show an output similar to this:

NAME="Ubuntu" VERSION="20.04.1 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.1 LTS" VERSION_ID="20.04" 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=focal UBUNTU_CODENAME=focal

As you can see, the Linux name is Ubuntu and the version is 20.04.1.

However, that’s not the only way to know the Linux distribution details. In this beginner’s tip, I’ll show you different ways to check which Linux you are running.

Find Linux distribution details

How to check Linux version

Method 1: Use /etc/os-release file

If you are familiar with the Linux directory structure, you probably already know that /etc directory contains the core configuration files of the system.

The os-release file in the /etc directory keeps the information about the Linux distribution. It gives you the distribution name, distribution version, release name or ID.

Here’s what it displays for Alpine Linux server running on Linode infrastructure.

handbook:~# cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.12.0 PRETTY_NAME="Alpine Linux v3.12" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/"

As you can see, the name of Linux distribution is Alpine Linux and the distribution version is 3.12.

The content of the /etc/os-release is usually different for different distributions. Distributions often use it to provide additional information like where to get support or file bugs etc.

For example, the /etc/os-release provides more lines for CentOS Linux.

NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8" 

However, all of them provide the Linux distribution name and version so it is a pretty reliable way to know which Linux you are running. In fact, it is the most reliable way.

Method 2: Use hostnamectl command

Most Linux distributions these days use systemd. On such a system, you can use the hostnamectl command to get Linux version detail.

For the same CentOS system that you saw above, hostnamectl provides the following details:

[[email protected] ~]# hostnamectl Static hostname: localhost.localdomain Transient hostname: li2498-99.members.linode.com Icon name: computer-vm Chassis: vm Machine ID: e3fe2be3e17be3e1763bf43e8337e68b Boot ID: 33d3052bbffd44b1869bbffd4b00d26c Virtualization: kvm Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-147.8.1.el8_1.x86_64 Architecture: x86-64

You can see the Linux version detail in the line starting with ‘Operating System’.

The hostnamectl command is primarily used for dealing with the hostname but if it provides other details why not use it?

Method 3: Use lsb-release command

This is NOT a command that you’ll find in all Linux distributions. I think it is mostly used by Debian/Ubuntu based distributions.

Читайте также:  Which linux like windows

You can use the lsb_release command with option -a and it will provide distribution details:

Don’t mind the No LSB modules are available line. It’s not an error of any kind.

[email protected]:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal

Bonus Tip: Find Linux kernel version

Now that you know which distribution you are running, perhaps you would also like to know about the Linux kernel version running on the system.

You can get the kernel details using the uname command in any Linux distribution.

The output shows only the Linux kernel version:

handbook:~# uname -r 5.4.43-1-virt

No prizes for guessing that the above system is running on Linux kernel version 5.4.43.

I hope you find this quick tip helpful in finding Linux version detail. If you have questions or suggestions, please let me know in the comment section.

Источник

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.

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.

Читайте также:  Null device in linux

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.

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.

Источник

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