On Windows
systeminfo
systeminfo
- Look at OS Name and OS Version in the output. To show only these lines:
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
ver
ver
It prints the version number, for example Microsoft Windows [Version 10.0.19045.3693].

On Linux
lsb_release
lsb_release -a
It lists the distributor, description, release and code name.
The os-release file
cat /etc/os-release
To show only the name:
grep PRETTY_NAME /etc/os-release
hostnamectl also shows the OS and the kernel:
hostnamectl
On CentOS
centos-release file
cat /etc/centos-release
rpm
rpm -q centos-release
redhat-release
cat /etc/redhat-release
On macOS
sw_vers
Quick recap
- Windows:
systeminfoorver. - Linux:
cat /etc/os-releaseorlsb_release -a. - CentOS:
cat /etc/centos-release.
