Accessing OS Information
The most straightforward method to check your OS details is by using the cat command on the /etc/os-release file. This file contains identification data of the Linux distribution and looks something like this:
$ cat /etc/os-release
You’ll receive output similar to:
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"
This file is present in most modern Linux distributions and provides a standardized way to access OS information.
Using the lsb_release Command
Another method is to use the lsb_release command, which displays Linux Standard Base (LSB) and distribution-specific information:
$ lsb_release -a
The output will provide detailed information about the distribution:
Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal
However, it’s worth noting that lsb_release might not be installed by default on some systems.
The hostnamectl Command
For systemd-based systems, hostnamectl can also be used to query and change the system hostname and related settings, including the OS information:
$ hostnamectl
It will display a comprehensive view, including the OS details:
Operating System: Ubuntu 20.04.1 LTS Kernel: Linux 5.4.0-42-generic Architecture: x86-64