Open a terminal by pressing Ctrl+Alt+T or by searching for "Terminal" in the Ubuntu Dash.
Use the lsb_release command with the -a option to display all available information about the distribution, including the Ubuntu version. Type the following command and press Enter:
lsb_release -a
The output will show various details about your Ubuntu installation, including the distribution ID, description, release number, and codename. Look for the "Description" or "Release" line to find the version number.
For example, it may show "Ubuntu 20.04.2 LTS" for Ubuntu 20.04.
Alternatively, you can use the "cat" command to read the contents of the /etc/lsb-release file, which contains information about the Ubuntu version. Type the following command and press Enter:
cat /etc/lsb-release
The output will display the contents of the lsb-release file, which includes the version information. Look for the line that starts with DISTRIB_DESCRIPTION to find the version number.
That's it! You have successfully checked your Ubuntu version using commands and code.