RDP Monster

How to Find OS Version with Command Line: Windows, Mac, Linux

How to Find OS Version with Command Line: Windows, Mac, Linux

Introduction

The ability to determine the version of your operating system is crucial to the administration of your system as well as software compatibility verification and troubleshooting. Although graphical user interfaces offer the information, command-line techniques provide advantages such as remote accessibility, scriptability, as well as detailed information on version. If you’re responsible for a single system as well as hundreds of servers being able to retrieve OS version information using commands-line interfaces is a crucial knowledge.

This complete guide explains command-line techniques for identifying operating system versions on Windows, Linux, and macOS platforms. Learn about specific commands for each platform that interpret output, and how to use tools for managing the system and automation.

 

What is OS Version Information ?

Components of OS Version Data

Major Version: Indicates significant release (Windows 10, Ubuntu 20.04)

Minor Version: Indicates incremental improvements

Build Number: Identifies specific compilation of OS

Kernel Version: Underlying core (particularly relevant for Linux)

Service Pack Level: Maintenance update level (Windows)

Architecture: 32-bit or 64-bit

Understanding these components enables accurate system identification and troubleshooting.

 

Windows OS Version Discovery

Using cmd Commands

systeminfo Command

systeminfo


Output includes:

  • OS Name (Windows 10 Pro, Windows Server 2019)

  • System Manufacturer

  • OS Version (version number)

  • OS Build (build number)

  • System Boot Time

  • Network Configuration

  • Windows Update information


Filtered Output (Specific Information)

systeminfo | find "OS Name"
systeminfo | find "OS Version"
systeminfo | find "System Boot Time"


Using PowerShell Commands

Get-ComputerInfo
Get-ComputerInfo | Select-Object OSName, OSVersion, OsBuildNumber

Windows Management Instrumentation (WMI)
Get-WmiObject -Class Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber

Windows Registry Query
Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object CurrentVersion, ReleaseId, BuildLabEx

Interpreting Windows Version Output

Version String Breakdown:

  • Version 21H2 = Windows 11 (Release 21H2)

  • Version 20H2 = Windows 10 (Release 20H2)

  • Build 19045 = Windows 10 latest

  • Build 22000 = Windows 11 initial

OS Names Identification:
Windows 10 Home
Windows 10 Pro
Windows 10 Enterprise
Windows 11 Home
Windows 11 Pro
Windows Server 2016
Windows Server 2019
Windows Server 2022

Windows Version History Quick Reference

Version Release Name Build Range
Windows 11 Current 22000+
Windows 10 Latest (21H2) 19044+
Windows Server 2022 Current 20348+
Windows Server 2019 Mainstream Support 17763+
Windows Server 2016 Extended Support 14393+

 

Linux OS Version Discovery

Using /etc/os-release

Viewing File Content
cat /etc/os-release

Output Example (Ubuntu):
NAME="Ubuntu"
VERSION="20.04.3 LTS"
ID=ubuntu
ID_LIKE=debian
VERSION_ID=20.04
HOME_URL="https://www.ubuntu.com/"

Filtering Specific Information
grep "PRETTY_NAME" /etc/os-release

Distribution-Specific Commands

Ubuntu/Debian
lsb_release -a # Complete information lsb_release -ds # Description

Red Hat/CentOS
cat /etc/redhat-release

Fedora
cat /etc/fedora-release

SUSE
cat /etc/SuSE-release

Kernel Version Information

uname -a # All information
uname -r # Kernel release
uname -s # Kernel name
uname -m # Hardware platform
uname -p # Processor type

 

Output Interpretation
Linux hostname 5.15.0-56-generic #62-Ubuntu SMP Fri Oct 7 10:50:38 UTC 2022 x86_64 GNU/Linux
| | | | | |
OS Host Kernel Version Build/Date Arch Platform

Complete System Information

hostnamectl # Hostname and OS information
 

macOS OS Version Discovery

Using system_profiler

system_profiler SPSoftwareDataType

Output includes:

  • System Software Overview

  • OS Version

  • Kernel Version

  • Build Number

  • Computer Name

Using sw_vers Command

sw_vers # Complete version information
sw_vers -productName
sw_vers -productVersion
sw_vers -buildVersion

Using uname Command

uname -a # Kernel and system information

macOS Version Mapping

Version Code Name Release Year
13 Ventura 2022
12 Monterey 2021
11 Big Sur 2020
10.15 Catalina 2019
10.14 Mojave 2018

 

Advanced Version Detection

Detecting Architecture (32-bit vs 64-bit)

Windows

powershell
[Environment]::Is64BitOperatingSystem
 

Linux

bash
getconf LONG_BIT
 

macOS

bash
arch
 

CPU and Hardware Information

Windows

wmic cpu get name, manufacturer
 

Linux

bash
cat /proc/cpuinfo
lscpu
 

macOS

bash
sysctl -n hw.model
 

Checking System Uptime

Windows

powershell
(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime
 

Linux

bash
uptime

 

macOS

bash
uptime
 

Scripting OS Detection

Cross-Platform Detection Script (Bash)

#!/bin/bash
echo "Operating System Information"
echo "============================"
 
# Detect OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
 echo "Operating System: Linux"
 if [ -f /etc/os-release ]; then
  . /etc/os-release
  echo "Distribution: $PRETTY_NAME"
fi
 echo "Kernel: $(uname -r)"
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Operating System: macOS"
 echo "Version: $(sw_vers -productVersion)"
echo "Build: $(sw_vers -buildVersion)"
else
  echo "Unknown OS: $OSTYPE"
fi
 
echo "Architecture: $(uname -m)"
echo "Hostname: $(hostname)"
 

PowerShell Cross-Server Detection

Get-ComputerInfo -Computer "server1", "server2" | `
  Select-Object PSComputerName, OSName, OsBuildNumber, OsVersion


Batch File OS Detection (Windows)

@echo off
for /f "tokens=3" %%i in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" ^| find "BuildLabEx"') do set BUILD=%%i echo Windows Build: %BUILD%
 
for /f "delims=" %%i in ('wmic os get caption ^| find "Windows"') do set
OSNAME=%%i
echo OS Name: %OSNAME%
 
 

Comparing Versions Programmatically

Bash Version Comparison

#!/bin/bash
 
VERSION1="20.04"
VERSION2="22.04"
 
# Convert versions to comparable numbers
ver1=$(echo "$VERSION1" | tr '.' ' ' | awk '{print $1*100+$2}')
ver2=$(echo "$VERSION2" | tr '.' ' ' | awk '{print $1*100+$2}')
 
if [ $ver1 -lt $ver2 ]; then
 echo "$VERSION1 is older than $VERSION2"
elif [ $ver1 -gt $ver2 ]; then
 echo "$VERSION1 is newer than $VERSION2"
else
 echo "Versions are identical"
fi

 

PowerShell Version Comparison

$version1 = [version]"10.0.19045"
$version2 = [version]"10.0.22000"

if ($version1 -lt $version2) {
  Write-Host "$version1 is older"
} else {
  Write-Host "$version1 is newer or equal"
}
 
 

Why System Administrators Query OS Information

Regular OS version querying is essential for:

Security Patching: Identify systems requiring security updates

Compatibility Verification: Ensure applications meet OS requirements

Inventory Management: Track OS deployment across infrastructure

License Compliance: Verify appropriate licensing for deployed versions

Troubleshooting: Identify OS-specific issues

Automation: Query version information in deployment scripts

 

Remote Infrastructure Management

Professional infrastructure management frequently requires querying OS versions across multiple systems. RDP.Monster enables efficient OS interrogation across distributed infrastructure:

Remote OS Detection Capabilities

  • SSH access for remote Linux/Unix interrogation

  • PowerShell Remoting for Windows server queries

  • Batch queries across multiple systems simultaneously

  • Automated reporting on OS versions and compliance

Infrastructure Monitoring Integration

  • Real-time OS version tracking

  • Automated alerts on outdated systems

  • Compliance reporting across infrastructure

  • Integration with automation workflows

Query and manage OS information across your entire infrastructure with RDP.Monster VPS solutions

Powerful Linux VPS Hosting

Experience full control and blazing performance with our Linux VPS. Perfect for hosting applications, managing servers, and optimizing your workflow.

Dedicated Servers

High-Performance Dedicated Servers

Need maximum control and power? Our Dedicated Servers offer unmatched performance for demanding tasks.

Frequently Asked Questions

Why does OS version matter for software compatibility?

Different OS versions have different feature sets, security models, and API compatibility.

Software compiled for one OS version may not function on significantly different versions.

How often should I check OS versions?

At minimum during security update cycles; continuously in automated infrastructure environments.

What's the difference between OS version and build number?

OS version indicates major/minor release; build number identifies specific compilation date and patches applied.

Can I determine OS version without administrator privileges?

Yes. Most OS version commands work with standard user privileges.

Some detailed hardware information requires elevation.

How do I keep OS versions current?

Configure automatic updates; regularly review patch releases; test updates in non-production environments before production deployment.

Is there a universal command that works across all operating systems?

uname -a works on Unix-like systems (Linux, macOS). Windows requires platform-specific commands (systeminfo or PowerShell).

What's the quickest way to check OS version remotely?

SSH command: ssh user@host "cat /etc/os-release" for Linux; PowerShell remoting for Windows.

Should I upgrade immediately when new OS versions release?

No. Test in non-production environments first, maintain current version until retirement date approaches.

Register to our reseller program

Your informations

If you have any question, contact us by clicking here !
Name(Required)
Enter your email address, you must have an account on manager.rdp.monster !

Your company

Enter your website address if you have one
Quickly explain how you're going to sell services to your customers. For example, talk to people on forums.

We're using cookies!

We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Accept", you consent to our use of cookies.