Find OS Version with Command Line: Windows, Linux, and macOS

Published June 20, 2024
Find OS Version with Command Line: Windows, Linux, and macOS
Cheap Dedicated Server

Find OS Version with Command Line: Windows, Linux, and macOS


 

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:

  1. Using ver Command:

    ver

      Using ver Command


    This command will display the OS version.

  2. Using systeminfo Command:

    systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

    Using systeminfo Command


    This command provides detailed information about your system, including the OS name and version.

  3. Using wmic Command:

    wmic os get Caption,Version,BuildNumber,OSArchitecture

    Using wmic Command


    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:

  1. Using Get-ComputerInfo:

    Get-ComputerInfo | Select-Object CsName, WindowsVersion, WindowsBuildLabEx

    Using Get-ComputerInfo


    This command provides comprehensive information about the computer, including the OS version.

  2. Using Get-WmiObject:

    Get-WmiObject -Class Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber

    Using Get-WmiObject


    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.

  1. Basic OS Version:

    uname -r

    Basic OS Version


    This command displays the kernel version.

  2. Detailed OS Information:

    uname -a

    Detailed OS Information


    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.

  1. Using lsb_release Command:

    lsb_release -a

    Using lsb_release Command


    This command displays detailed information about the Linux distribution.

  2. Using /etc/os-release File:

    cat /etc/os-release

    Using etc os-release File


    This file contains information about the OS, including the name and version.

  3. Using /etc/lsb-release File:

    cat /etc/lsb-release

    Using etc lsb-release File


    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.

  1. Basic OS Information:

    sw_vers

    Basic OS Information


    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.

  1. Detailed OS Information:

    system_profiler SPSoftwareDataType

    Using system_profiler Command


    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.


 

Find OS Version with Command Line: Windows, Linux, and macOS ​(F.A.Q)

How can I find the OS version on Windows using the command line?

You can use the Command Prompt or PowerShell. In Command Prompt, type ver or systeminfo | findstr /B /C:"OS Name" /C:"OS Version". In PowerShell, use Get-ComputerInfo | Select-Object CsName, WindowsVersion, WindowsBuildLabEx.

What command do I use to find the OS version on Linux?

You can use uname -r for the kernel version or uname -a for detailed information. Additionally, lsb_release -a, cat /etc/os-release, or cat /etc/lsb-release provide detailed OS version information.

 

How do I check the OS version on macOS using the terminal?

Use the sw_vers command to get basic OS information. For more detailed software information, use system_profiler SPSoftwareDataType.

What is the difference between uname and lsb_release on Linux?

The uname command provides kernel and system information, while lsb_release gives detailed information about the Linux distribution, including the name and version. lsb_release -a is typically more descriptive for OS version details.