Pretty basic, to get the version of Ubuntu from a command-line terminal, run the command:
grep -wi version /etc/*release
The command grepped for the word version (ignoring case) in the release text file (/etc/os-release file in case of Ubuntu) of your OS distribution. This will output the exact short VERSION string, one line.
This command is the same across all major Linux, GNU/Linux, Debian and their docker images or containers, and should work on:
- Ubuntu 22.04
- Ubuntu older versions
- RedHat Linux
- Kali Linux
- Linux or Debian-based Docker containers etc.
For example, running the same command in Kali Linux (to check the release version of Kali Linux)
How to check complete OS version details in Ubuntu and other Linux distribution?
Detailed information about your distro version is available if you read the full os-release file, as shown below.
Let’s read the release file for the long release version and related information.
Full version detail of Ubuntu 20.04 – Example:
[email protected]:~$ cat /etc/*release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS" NAME="Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.5 LTS" VERSION_ID="20.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=focal UBUNTU_CODENAME=focal
If you have more questions on Ubuntu or VirtualBox, Docker, or Shell Scripting – please refer to these sections, also feel free to ask us.