How to Check Ubuntu Version Using Bash Scripts? [5 Methods]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

Checking the version of Ubuntu typically refers to determining the specific release version or codename of the Ubuntu operating system installed on a system. To check the version of Ubuntu you’re running, you can use the following command:

lsb_release -a

Apart from this, there are several ways to check the Ubuntu version. They are listed below:

1. Check Ubuntu Version Using “lsb_release” Command

The lsb_release is a command used to display Linux Standard Base (LSB) and distribution-specific information about the Linux distribution you are using. You can check the Bash version using the lsb_release command along with the release option and -a argument:

lsb_release -a

executing lsb_release -aIn the image above, running the command gives you the Ubuntu version.

2. Check Ubuntu Version Using “hostnamectl” Command

The hostnamectl command is a utility in Linux used for querying and changing the system hostname and related settings. It also allows users to view and modify the hostname as well as related settings and Ubuntu versions.

hostnamectl

executing hostnamectlAfter running the command, you can see the Ubuntu version on your computer screen.

3. Check Ubuntu Version Using “neofetch” Command

The neofetch command is a simple, yet popular, command-line utility used to display system information and details about the operating system in a visually appealing way. You can use it to obtain system information including the version of your Ubuntu:

neofetch

executing neofetch command

Note: By default, neofetch package may not be installed in your system. Follow this article to install the neofetch command.

In this picture, you can see the system information including the Ubuntu version is shown in a formatted, colored way.

4. Check Ubuntu Version from the Issue File

In Linux, the issue file contains information about the operating system release and version. It is typically located in the /etc/ directory. You can write a Bash script that will open this file and show you the version of Ubuntu.

cat /etc/issue

previewing issue fileAs you can see in this image, after running the script, I got the Ubuntu version printed on my screen.

5. Check Ubuntu Version from the Os-release File

The /etc/os-release file in Ubuntu is a vital source of information about the operating system. It provides a variety of information about the Ubuntu distribution, such as the version, codename, and other crucial characteristics.

cat /etc/os-release

previewing os-release fileHere you can see that running the Bash script printed information of the os-release file, including the Ubuntu version.

Conclusion

Knowing the Ubuntu version is an easy task, no matter what process you follow. But checking the version using Bash scripting is easier because, even if the version updates, you just have to run a script to check the most recent version. You can do it with just one command in seconds using a bash script. Feel free to let me know if you have further queries on this topic.

People Also Ask

How do I check the Ubuntu version in a shell?

To check the Ubuntu version in the shell you can use the command line interface, and type any of these commands lsb_release -a, cat etc/os-release, or cat /etc/issue.

How do I check the Linux kernel version?

You can use the command uname -r to check the Linux Kernel version that you are using. It will show users the version of Linux kernel as well as some additional information.

How do I check the node version in Ubuntu?

If you want to know the node version in Ubuntu, you must have installed the node js in your system. To install it, run the command sudo apt install nodejs, and then run the command node -v.

How do I check the WSL version on Ubuntu?

To check the WSL version, open the PowerShell or Windows Command Prompt. Then enter the command wsl -l -v and this will display the WSL version in Ubuntu.

Related Articles


<< Go Back to Bash Script Examples | Bash Scripting Basics | Bash Scripting Tutorial

Rate this post
Lamisa Musharrat

Hello there. My name is Lamisa Musharat, and I'm an Linux Content Developer Executive at SOFTEKO. I earned a bachelor's degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology (BUET).I learned Linux out of my curiosity and now I find it useful as automation is easier using Linux. I take great pleasure in assisting others with Linux-related issues. I really want you to enjoy and benefit from my efforts.Read Full Bio

Leave a Comment