It is quite easy to know which version of the Debian operating system we are using and this mostly happens when you log in to the Debian server after a long time or when looking for a software that is available for a specific version of Debian only.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Debian Linux queries.
In this context, we shall look into different methods of checking OS version.
1. How to Check Debian Version using Command Line ?
It is best practice to check version using command line as it is not depend on anything. So here we are going to check Debian version using lsb_release (Linux Standard Base) utility. Commonly, this method is best because it will work regardless of any desktop environment or version you are using:
$ lsb_release -a
It will show output as below:
Output
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.5 (stretch)
Release: 9.5
Codename: stretch
From the above output you can see that Description line is showing OS version.
Instead of print all the details of your Debian system, you can simply print only distribution name by passing -d with command:
$ lsb_release -d
The output should be similar like below:
Output
Description: Debian GNU/Linux 9.5 (stretch)
2. How to Check Debian Version using /etc/os-release file ?
os-release file contains identification data of operating system and this available only with newer Debian distribution:
$ cat /etc/os-release
The output will be similar as below:
Output
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
3. How to Check Debian Version using /etc/issue file ?
Like, os-release the /etc/issue file also contains the system identification text. Using below command you can see it:
$ cat /etc/issue
It will show output as following:
Output
Debian GNU/Linux 9 \n \l
4. How to Check Debian Version using hostnamectl command ?
Mostly, hostnamectl command is used to set hostname in Debian systems but you also can check the system details using it. Execute below command:
$ hostnamectl
This command will work only for Debian 9 and newer versions. It should show output as below:
Output
Static hostname: local.linuxapt
Icon name: computer-vm
Chassis: vm
Machine ID: 287b816ad03c4f429f7bb49501983e1c
Boot ID: 7fd5cca4dd5c41f6ac53214e11fa3f57
Virtualization: oracle
Operating System: Debian GNU/Linux 9 (stretch)
Kernel: Linux 4.9.0-8-amd64
Architecture: x86-64
This way, you can get your OS version using any one of these method.
This article covers how to check OS version using different methods. You can get more information on Debian releases at official site of the Debian Releases.
The easiest way on how to check what Debian version you are running is to simply read a contents from /etc/issue file. Execute the command:
# cat /etc/issue
Also, you can check for /etc/os-release release file:
# cat /etc/os-release