Support tickets, installers and security advisories usually start by asking which OS version you're running. On a remote server you can't open a settings window to check, so you need a command. Whether you're troubleshooting an urgent software issue or verifying compatibility before an install, the command line is the fastest way to get an accurate answer — no menus, no guessing.
Below are the commands for Windows, macOS and Linux, with the fields that matter in each and whether they suit a script. Every command here runs without admin or root rights.
⚡ Quick Answer: OS Version Commands by Operating System
| OS | Command | Returns | Best for |
| Windows | systeminfo |
OS name, version, build | CMD, remote sessions |
| Windows | Get-ComputerInfo |
OS name, version, build as objects | PowerShell scripts |
| Windows | winver |
Dialog with version and OS build | Quick visual check |
| macOS | sw_vers |
ProductName, ProductVersion, BuildVersion | Terminal and scripts |
| Linux | cat /etc/os-release |
Distribution name and version | Any modern distro |
| Linux | hostnamectl |
OS, kernel, hostname, architecture | systemd servers |
| Linux | uname -r |
Kernel release only | Driver and module checks |
🔍 Why You Should Know the OS Version
Knowing your operating system version is vital for several reasons:
- Security and updates: Newer OS versions contain important security patches. Knowing your version lets you confirm the system is up to date and safe.
- Software compatibility: Some programs only work with specific OS versions. Knowing yours avoids install failures and connection issues.
- Troubleshooting: Many forums and knowledge bases organize fixes by OS version, so the right number helps you find the right solution.
- New features: Upgrades bring new capabilities. Knowing your version tells you whether you're missing out.
How to Find OS Version with Command Line for Windows
If you need a dedicated walkthrough with screenshots and other methods, see How to check Windows version — this section focuses on the command-line options.
Use systeminfo in Command Prompt
Microsoft's "What version of Windows am I running?" page recommends this filter, which works in both CMD and PowerShell:
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"The "OS Version" line contains the build number (for example, 10.0.xxxxx). Running systeminfo without the filter prints the full report, which includes install date, hotfixes and memory — and takes a few seconds to finish.
Use winver for a quick visual check
Press Win+R, type winver and press Enter. The About Windows dialog shows the version (such as 23H2) and the OS build. It's a GUI window with no text output, so a script can't use it.
Use ver for a fast basic result
verver prints a single line such as Microsoft Windows [Version 10.0.xxxxx.xxxx]. It runs instantly, but Windows 10 and Windows 11 both report as 10.0 — the build number is how you tell them apart. For more CMD shortcuts that surface system details, see CMD commands for computer information.
Use PowerShell with Get-ComputerInfo
Get-ComputerInfo | Select-Object OsName, OsVersion, OsBuildNumber, OsDisplayVersionThis returns objects instead of text, so you can compare values in a script without parsing strings. For a faster lookup, read the registry directly:
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" | Select-Object DisplayVersion, CurrentBuild, UBRCurrentBuild plus UBR gives you the full build, for example 22631.xxxx.
Avoid relying on wmic
Older guides suggest wmic os get Caption,Version. Microsoft's WMIC removal notice says WMIC has been removed from currently supported versions of Windows 11, though WMI itself is still supported. If you need WMI data, use PowerShell's Get-CimInstance Win32_OperatingSystem in place of wmic.
🍎 How to Check the macOS Version in Terminal
Use sw_vers
% sw_vers
ProductName: macOS
ProductVersion: 15.6.1
BuildVersion: 24G90ProductNameis the OS name.ProductVersionis the marketing release number (15.6.1 is a macOS Sequoia point release).BuildVersionis Apple's internal build identifier. Apple support and beta testers often ask for it.
Use sw_vers -productVersion for scripts
The sw_vers reference lists single-field flags. Each one prints only its value, which is the easiest output to parse:
sw_vers -productVersion
sw_vers -buildVersionUse system_profiler for full software details
system_profiler SPSoftwareDataTypeThis adds the kernel version, boot volume, computer name and uptime. It's slower than sw_vers, so save it for a support report.
🐧 How to Check the Linux Version from the Command Line
Knowing your Linux version via the command line is faster and more efficient than navigating menus. There are several commands, each with a slightly different purpose.
Use cat /etc/os-release for the distribution version
cat /etc/os-releaseThe systemd os-release specification defines /etc/os-release and /usr/lib/os-release as the files that hold operating system identification data. Nearly every modern distro ships this file. Look at PRETTY_NAME, VERSION_ID and ID. Because the file uses shell variable syntax, a script can source it:
. /etc/os-release && echo "$ID $VERSION_ID"📝 Ready to become a Bash pro? Check out our comprehensive Bash Scripting Cheat Sheet for all the commands you need.
Use hostnamectl for OS and kernel details
hostnamectlOn systemd systems, this shows the operating system, kernel, architecture and hostname together. It doesn't work in most Docker containers or on non-systemd distros such as Alpine. In those cases, fall back to /etc/os-release.
Use uname -r for the kernel version only
uname -rThis prints the running kernel release, for example 6.8.0-xx-generic. It doesn't tell you whether the machine runs Ubuntu, Debian or Rocky Linux. uname -a adds the hostname and architecture, but it still doesn't show the distro. For a deeper dive into kernel releases, see how to check kernel version.
Use lsb_release -a if it's available
lsb_release -aThis gives clean output on Ubuntu and Debian, but minimal installs and RHEL-family servers often don't include it. If you get command not found, either read /etc/os-release or install the package (lsb-release on Debian/Ubuntu, redhat-lsb-core on older RHEL/CentOS). For Ubuntu-specific guidance, see How to check Ubuntu version.
📦 Distribution-Specific Notes
- Ubuntu and Debian: use
cat /etc/os-releaseorlsb_release -a. Debian also keeps the point release in/etc/debian_version— see how to check Debian version for the full walkthrough. - RHEL, CentOS, Rocky Linux and AlmaLinux: use
cat /etc/os-release.cat /etc/redhat-releasealso works on every RHEL-family system./etc/centos-releaseexists only on CentOS — see how to check CentOS version for details.
If you're choosing a distro in the first place, see best Linux distributions for a comparison.
🔢 OS Version vs Kernel Version vs Build Number
People often mix up these three numbers in support tickets, but each answers a different question:
- OS version is the product or distribution release, such as Windows 11 23H2, macOS 15.6.1 or Ubuntu 24.04.
- Kernel version is the kernel currently running. On Linux, you can update the kernel without changing the distro release, and the reverse is also possible.
- Build number is a vendor identifier for an exact compiled release. On Windows it's the OS build (22631.xxxx); on macOS it's BuildVersion (24G90).
If an advisory lists a fixed build, compare build numbers. If a package needs "Ubuntu 22.04 or later," check VERSION_ID.
🌐 Best Commands for Remote Servers and Automation
Over SSH, the human-readable choices are hostnamectl and cat /etc/os-release on Linux, sw_vers on macOS, and systeminfo on Windows (through SSH or PowerShell remoting). You can also check a box without logging in interactively:
ssh user@server 'cat /etc/os-release'For scripts, pick commands that return one value or structured data, and leave winver out entirely:
- On Linux, source
/etc/os-releaseand read the variables. - On macOS, use
sw_vers -productVersion. - On Windows, use
Get-ComputerInfoor the registry query in PowerShell.
🚨 Common Errors and Troubleshooting
- "command not found" for lsb_release or hostnamectl: the package is missing, or the system doesn't run systemd. Read
/etc/os-releaseor/usr/lib/os-release. - hostnamectl fails in a container: containers usually have no systemd. The container's
/etc/os-releasedescribes the image, anduname -rshows the host's kernel. - Permission issues: every command here runs without admin or root rights.
Get-ComputerInfomay leave a few fields empty for a standard user, but the OS fields still fill in. - The wmic "not recognized" error on Windows 11: the tool has been removed. Switch to PowerShell.
🧩 Conclusion
Sometimes you need to know the operating system version fast — for a support ticket, a compatibility check, or a troubleshooting step. On Windows, systeminfo and ver handle CMD, and Get-ComputerInfo handles PowerShell. On macOS, sw_vers is all you need. On Linux, cat /etc/os-release and hostnamectl cover every common distro. The commands here work for every user, from a quick one-off check to an automated script — and if you need a reliable environment to run them on, explore Linux VPS hosting from MonoVM, or spin up a dedicated Windows VPS for Windows-based workloads.
Hello, everyone, my name is Lisa. I'm a passionate electrical engineering student with a keen interest in technology. I'm fascinated by the intersection of engineering principles and technological advancements, and I'm eager to contribute to the field by applying my knowledge and skills to solve real-world problems.