Knowing the version of your operating system (OS) is crucial for compatibility checks, troubleshooting, and ensuring your system meets the requirements for certain applications. Using the command line to find this information is quick and efficient. In this blog, we’ll explore how to determine the OS version using command-line tools for Windows, Linux, and macOS.
Finding OS Version on Windows
Using Command Prompt
The Command Prompt is a built-in Windows application that provides a command-line interface for interacting with the OS. Here are a few commands to find the OS version:
- Using
ver
Command:
ver
This command will display the OS version.
- Using
systeminfo
Command:
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
This command provides detailed information about your system, including the OS name and version.
- Using
wmic
Command:
wmic os get Caption,Version,BuildNumber,OSArchitecture
This command retrieves various details about the OS, including the version and build number.
Using PowerShell
PowerShell is a more advanced command-line shell and scripting language. Here’s how to find the OS version with PowerShell:
- Using
Get-ComputerInfo
:
Get-ComputerInfo | Select-Object CsName, WindowsVersion, WindowsBuildLabEx
This command provides comprehensive information about the computer, including the OS version.
- Using
Get-WmiObject
:
Get-WmiObject -Class Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber
This command retrieves details about the OS using WMI (Windows Management Instrumentation).
Finding OS Version on Linux
Using uname
Command
The uname
command in Linux provides system information.
- Basic OS Version:
uname -r
This command displays the kernel version.
- Detailed OS Information:
uname -a
This command provides comprehensive information about the system.
Using /etc/*release
Files
Most modern Linux distributions include files in the /etc
directory that contain OS version information.
- Using
lsb_release
Command:
lsb_release -a
This command displays detailed information about the Linux distribution.
- Using
/etc/os-release
File:
cat /etc/os-release
This file contains information about the OS, including the name and version.
- Using
/etc/lsb-release
File:
cat /etc/lsb-release
This file provides additional distribution-specific information.
Finding OS Version on macOS
Using sw_vers
Command
The sw_vers
command in macOS provides software version information.
- Basic OS Information:
sw_vers
This command displays the product name, version, and build number of the OS.
Using system_profiler
Command
The system_profiler
command provides detailed information about the hardware and software of the system.
- Detailed OS Information:
system_profiler SPSoftwareDataType
This command displays detailed software information, including the OS version.
Conclusion
Using the command line to find the OS version is a quick and efficient method across different operating systems. Whether you’re using Windows, Linux, or macOS, these commands can provide you with the necessary details about your OS version. This knowledge is not only useful for system administrators and developers but also for any user who needs to check their system’s compatibility with certain software or troubleshoot issues.