Linux
How to Check OS and Version Using a Linux Command
February 28, 2023
This guide is part of the "Snippets" series. This series is focused on providing simple and accessible tutorials on various topics relating to development!
You can check the operating system and version using the uname
command in Linux.
Here's how to do it:
uname -a
The output will contain information about the operating system, including the version number. For example:
Linux hostname 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14 16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
In this output, the first word ("Linux" in this example) indicates the operating system, while the version number ("4.15.0-143-generic" in this example) is also listed.
Alternatively, you can use the following command to display the operating system version only:
lsb_release -a
This command will output information about the Linux distribution, including the version number. For example:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
In this output, the operating system is Ubuntu, and the version is 20.04.3 LTS.