In this tutorial, we will go over the easiest methods to check Ubuntu version from the terminal. You can use any of the methods below depending on what you need. The outputs that the commands provide are very basic, but at the end of the tutorial, we’ve shown some APT packages that give the version information, in a really beautiful ASCII format.
Files That Contain Ubuntu Version Details
There are a few configuration files that contain details of the version and the release information of the Linux distribution you’re on. So, if you’re looking for files that can provide you with the required details, keep reading.
1. LSB-Release File
LSB stands for Linux Standard Base. The lsb-release file is located in /etc/lsb-release directory. We can run the cat command to output the contents of this file.
[email protected]:~# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"
2. Issue File in Ubuntu
The /etc/issue file contains information that you see right before a terminal prompt is displayed after logging in.
This file is editable by users to allow the display of a custom message before the login prompt is displayed. But if you’re sure there have been no manual changes to the file, it will contain the version of the distribution.
[email protected]:~# cat /etc/issue Ubuntu 18.04.3 LTS n l
3. OS-Release File
Another file that offers detailed information about Ubuntu versions is the OS-Release file.
[email protected]:~# cat /etc/os-release NAME="Ubuntu" VERSION="18.04.3 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.3 LTS" VERSION_ID="18.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=bionic UBUNTU_CODENAME=bionic
Commands To Check Your Ubuntu Version
Let’s look at the commands that will allow us to check the Ubuntu version from the terminal.
This command gives a prettier output of what’s inside the /etc/lsb-release file.
[email protected]:~# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.3 LTS Release: 18.04 Codename: bionic
[email protected]:~# lsb_release -d Description: Ubuntu 18.04.3 LTS
Another useful command is the hostnamectl command that will allow you to view very detailed information about the system you’re working on.
[email protected]:~# hostnamectl Static hostname: ubuntu Icon name: computer-vm Chassis: vm Machine ID: 34ba2d5d0e424b348659116920aacb35 Boot ID: ea6f791cea804300ae24faf4992dea44 Virtualization: kvm Operating System: Ubuntu 18.04.3 LTS Kernel: Linux 4.15.0-74-generic Architecture: x86-64
Check Ubuntu Version With Pretty Outputs
There are many utilities that will satisfy the nerd within you. For a simple task such as finding the version of your Linux distribution, developers spent the time to build (well-known ones) utilities that will print a pretty output with the required OS information.
These are packages that you need to install using the apt install command before they become available.
The first command is the screenfetch command. Below is an example of what the default output looks like.
[email protected]:~# screenfetch
This sure is pretty! But this is just the default. Enter the command with the –help option and you’ll see how customizable everything in this output is.
Similar to screenfetch, neofetch offers a really pretty ASCII character design output with completely customizable characters and colors.
[email protected]:~# neofetch
What Version Of Debian Is Ubuntu Based On?
You know that Ubuntu is built with Debian as a base. To know which version of Debian your Ubuntu is built on, there’s a Debian_version file in the /etc/ folder.
[email protected]:~# cat /etc/debian_version buster/sid
Now you know how to check the version of your distribution along with two utilities that will allow you to prettify your outputs. We hope this tutorial has been useful to you.