Ubuntu is one of the most widely used, open-source, and freely available Linux distributions. It is available in three editions: “Server”, “Desktop”, and “Core”. Ubuntu releases new versions regularly to enhance the user experience and facilitate them with new features and security updates. The most recent release of Ubuntu is “Ubuntu 24.04” (as of April 2024).
Although Ubuntu is one of the most user-friendly, feature-rich, and customizable operating systems, it may not be compatible with all third-party software. Therefore, it is recommended to check the Ubuntu version before installing any specific third-party tool. To do this, Ubuntu offers several CLI and GUI methods that will be discussed in this post.
Content Overview
Let’s start with the terminal commands.
Check the Ubuntu Version Via Terminal
We can check the Ubuntu version via the terminal using commands like “lsb_release”, “hostnamectl”,
“cat /etc/os-release”, “cat /etc/*release”, “cat /etc/lsb-release”, or “cat /etc/issue”. Other than these commands we can also use the “screenfetch” and “neofetch” utilities to check the Ubuntu version installed on our system.
1.1 Checking Ubuntu Version Using lsb_release Command
lsb_release is a command line utility in Linux that retrieves the LSB module and distribution-specific information. We can execute this command with the “-a” option to retrieve all the information about the installed Linux distribution:
lsb_release -a
On successful execution, this command returns the distribution name, description of the installed Linux distribution, version, and codename of the Ubuntu version:
The output shows that Ubuntu 24.04 (codenamed noble numbat) is installed on our system.
You can use the “lsb_release” command with some other options to get only specific information about the installed Ubuntu version:
Options | Description |
---|---|
-d | This option retrieves only a description of the installed Linux distribution. |
-ds | Combine the “d” option with the “s” to shorten the output. |
-c | Use this option to get only the code name of the distribution installed on your system. |
-dc | Use the “d” and “c” options combined with the lsb_release command to get the distribution’s description and code name. |
-r | This option retrieves the release number of the installed Linux distribution. |
-rs | Use the “rs” option to shorten the output of the r option. |
Let’s implement some of the above-given options practically to see how they work in Ubuntu:
lsb_release -d
lsb_release -ds
lsb_release -dc
lsb_release -rs
Here is the resultant output for the stated commands:
1.2 Checking the Ubuntu Version Using cat /etc/lsb-release File
Alternatively, we can access and display the contents of the “lsb-release” file using the cat command. The file contains the details of your OS, including the installed Ubuntu version:
cat /etc/lsb-release
Upon executing the mentioned command, we will get the name of the Linux distribution installed on our system along with its version, codename, and a brief description of our Linux distribution.
1.3 Checking Ubuntu Version Using hostnamectl Command
In Ubuntu, the hostnamectl command is used to change/update the system hostname or related settings. For this purpose, we can use different options with this command such as “status”, “set-hostname”, etc. However, if we execute this command without any option, it retrieves detailed information about the installed Linux distribution:
hostnamectl
The output of the hostnamectl command shows that we are using Ubuntu 24.04 LTS on VirtualBox:
1.4 Checking the Ubuntu Version Using cat /etc/os-release File
The “/etc/os-release” file includes precise information about our Linux distribution that can be viewed using the cat command, as follows:
cat /etc/os-release
This command retrieves the name of the installed Linux distribution in a human-friendly format. Also, it shows the distribution version, codename, unique identifier for a Linux distribution, information about the distribution’s family, and much more, as shown in the following output:
1.5 Checking the Ubuntu Version Using cat /etc/*release File
This works similarly to the “cat /etc/os-release” command. The only difference is that “cat /etc/os-release” retrieves the distribution information from the “os-release” file. On the other hand, the “cat /etc/*release” command returns the distributions’ information from all those files of the “etc” directory that ends with “release”. Here is a demonstration:
cat /etc/*release
The output confirms that the “cat /etc/*release” command retrieves the Ubuntu version with some additional information like “DISTRIB_ID”, “DISTRIB_RELASE”, etc.
1.6 Checking the Ubuntu Version Using cat /etc/issue File
The “/etc/issue” file contains text that is shown to the users when they log in via SSH. We can access/use this file via the cat command to get the Ubuntu version:
cat /etc/issue
Alternatively, you can execute the following command to get the Ubuntu version. This time you will get a cleaner output as compared to the “cat /etc/issue” command:
cat /etc/issue.net
1.7 Checking the Ubuntu Version Using Screenfetch
Screenfetch is a bash script that shows the system’s detailed information including its version. It detects the distribution installed on your system and retrieves a logo as ASCII art in the terminal. However, this script must be installed on your system before use. To do this, execute the following command from the Ubuntu terminal:
sudo apt install screenfetch
Once the “screenfetch” is successfully installed, execute the “screenfetch” command without any additional option to check the Ubuntu version:
screenfetch
1.8 Checking the Ubuntu Version Using Neofetch
“Neofetch” is also a bash script that can check/retrieve the Ubuntu version. This utility is an advanced variant of the screenfetch bash script. By default, it is not installed on our system, so first we need to install it using the following command:
sudo apt install neofetch
Once this utility is successfully installed, we can use it to check the Ubuntu version:
neofetch
1.9 Checking the Ubuntu Version via gnome-control-center
“gnome-control-center” is a GUI tool that lets us manage and configure different GNOME settings. The About page of the gnome control center contains information about the Ubuntu version, hardware model, processor, etc. To access this page simply execute the following command from the terminal:
gnome-control-center about
Check the Ubuntu Version Via GUI
We can also use the Ubuntu GUI to check its version. For this purpose, first, open settings and navigate to the “about” section:
The About page contains all the essential details regarding the installed Linux distribution, including the version:
This is how you can check the Ubuntu version from CLI and GUI.
Bottom Line
To check the Ubuntu version, open the terminal and execute the “lsb_release” or the “hostnamectl” command. Apart from these commands, you can also get the Ubuntu version by accessing the files like “/etc/os-release”, “/etc/*release”, “/etc/lsb-release”, or “/etc/issue” using the cat command. Also, you can use the “neofetch” or “screenfetch” bash scripts for more user-friendly and visually appealing results.
Some of the mentioned methods show only the installed Ubuntu version while others provide complete information about your operating system. The choice of method to check the Ubuntu version totally relies on your needs and preferences. However, the most convenient and recommended approaches are the “lsb_release” and “hostnamectl” commands.
Check our LinkedIn company page