How to Find OS Version with Command Line: Windows, Mac, Linux
- November 8, 2025
- 10:56 pm
- Tutorials

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-ComputerInfoGet-ComputerInfo | Select-Object OSName, OSVersion, OsBuildNumber
Windows Management Instrumentation (WMI)Get-WmiObject -Class Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber
Windows Registry QueryGet-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 Contentcat /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 Informationgrep "PRETTY_NAME" /etc/os-release
Distribution-Specific Commands
Ubuntu/Debianlsb_release -a # Complete information
lsb_release -ds # Description
Red Hat/CentOScat /etc/redhat-release
Fedoracat /etc/fedora-release
SUSEcat /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 InterpretationLinux 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 informationmacOS 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
[Environment]::Is64BitOperatingSystemLinux
getconf LONG_BITmacOS
archCPU and Hardware Information
Windows
wmic cpu get name, manufacturerLinux
cat /proc/cpuinfo
lscpumacOS
sysctl -n hw.modelChecking System Uptime
Windows
(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTimeLinux
uptime
macOS
uptimeScripting OS Detection
Cross-Platform Detection Script (Bash)
#!/bin/bashecho "Operating System Information"echo "============================"# Detect OSif [[ "$OSTYPE" == "linux-gnu"* ]]; thenecho "Operating System: Linux"if [ -f /etc/os-release ]; then. /etc/os-releaseecho "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)"elseecho "Unknown OS: $OSTYPE"fiecho "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=%%iecho OS Name: %OSNAME%Comparing Versions Programmatically
Bash Version Comparison
#!/bin/bashVERSION1="20.04"VERSION2="22.04"# Convert versions to comparable numbersver1=$(echo "$VERSION1" | tr '.' ' ' | awk '{print $1*100+$2}')ver2=$(echo "$VERSION2" | tr '.' ' ' | awk '{print $1*100+$2}')if [ $ver1 -lt $ver2 ]; thenecho "$VERSION1 is older than $VERSION2"elif [ $ver1 -gt $ver2 ]; thenecho "$VERSION1 is newer than $VERSION2"elseecho "Versions are identical"fiPowerShell 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.
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?
Software compiled for one OS version may not function on significantly different versions.
How often should I check OS versions?
What's the difference between OS version and build number?
Can I determine OS version without administrator privileges?
Some detailed hardware information requires elevation.
How do I keep OS versions current?
Is there a universal command that works across all operating systems?
What's the quickest way to check OS version remotely?
Should I upgrade immediately when new OS versions release?
Related Posts




