How to check OS version in Linux from command line ?
This tutorial guides you on how to check OS version in Linux from command line. Linux is a open source and free Operating System. There are various distributions of Linux available. For example, Debian, Ubuntu, CentOS, Fedora etc.,. We need to know the OS Version and other details of our Linux. Therefore, you can patch it up with necessary updates and packages as and when required.
Check OS version in Linux from command line
There are various ways using which you can find out the Linux OS version and other details. Before you trying these approaches make sure that you have SSH access to the Linux machine.
Once you know the SSH credentials of your Linux system then login using Putty. After that, follow any one of the following ways to find the OS version from command line.
Using /etc/os-release
Type the following command to find the OS version and other useful information.
$ cat /etc/os-release
Output
NAME="Ubuntu" VERSION="20.04.2 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.2 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-poli cy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal
You can also use grep command to filter out and check specific information that you are looking for. For example, let’s see how to filter out only the OS version using grep and the /etc/os-release command.
~$ grep '^VERSION' /etc/os-release
Output
VERSION="20.04.2 LTS (Focal Fossa)" VERSION_ID="20.04" VERSION_CODENAME=focal
hostnamectl command – OS & Kernel Version
The hostnamectl command can be used to control Linux system hostname and related settings. Try running the following command to find the OS and Kernel version details.
~$ hostnamectl
Output
Static hostname: ubuntu-virtual-machine Icon name: computer-vm Chassis: vm Machine ID: c0328e0dbdf8438dac5abf58470aa747 Boot ID: 94f2c038b7ee42138b3455cf1d7a3569 Virtualization: vmware Operating System: Ubuntu 20.04.2 LTS Kernel: Linux 5.4.0-42-generic Architecture: x86-64
Check OS version using lsb_release command
The lsb_release command prints LSB(Linux Standard Base) information about the specific Linux distribution. This information includes distributor ID, description, release version, codename as shown in the below example.
$ lsb_release -a
Output
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal
uname commands
The following uname commands can be used to just print the OS Kernel version details.
$ uname -r 5.4.0-42-generic $ uname -a Linux ubuntu-virtual-machine 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
proc version to check Kernel Version
Similar to uname command proc version command also can be used to check Kernel Version as shown below.
$ cat /proc/version
Output
Linux version 5.4.0-42-generic (buildd@lgw01-amd64-038) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020
Check OS version using /etc/issue.net
Try running cat /etc/issue.net command to check only the OS version of your Linux.
For example,
~$ cat /etc/issue.net
Output
Ubuntu 20.04.2 LTS
That’s it. You have learnt many ways using which you can check OS version and kernel version in Linux from command line.
Hope it is helpful 🙂
Also See:
- Set or change root password in Ubuntu Linux
- Linux: sudo: apt-get: command not found
- How to Start Stop Restart MariaDB on Linux OS ?
- Putty Fatal Error No supported authentication methods available
- How to find which users belongs to a specific group in linux
- Give write permissions for specific user or group for specific folder in linux
- How to unzip a zip file from Terminal (Google Cloud Shell)
- Build a Docker Image with a Dockerfile and Cloud Build in GCP?
- How to create GCP project on Google Cloud Platform
- MariaDB – How to set max_connections permanently ?
- How to create GCP project on Google Cloud Platform
- Is it possible to change Google Cloud Platform Project ID ?
- Create non-root SSH user account and provide access to specific folders
- MySQL : How to grant all privileges to the user on database ?
- How to install OpenJDK 11 in Ubuntu Machine ?
- Amazon Linux AMI : apt-get command not found
- How to get the first and last element of a list in Python ?
- Connect to Github using SSH ?
- Find the PID of the process that is using specific port ?