How to Find OS Version with Command Line? [Windows, Linux, and macOS]

Learn how to quickly find your OS version using simple command line commands. Follow our easy guide for Windows, macOS, and Linux.

Updated: 12 Jun, 24 by Lisa P 9 Min

List of content you will read in this article:

Imagine you`re troubleshooting a software issue and you need to know the version of your operating system. It is urgent! What would you do in this situation? There are graphical ways to find the OS version, but we recommend using command line. why? Because it`s easy and quick! If you don’t know How to Find OS Version with Command Line you`re in the right place. In this blog post, we`ll mention all the methods that you can Check OS Version with Command Line. No different your system is Windows, macOS, Linux, or its distributions.

Knowing your operating system version is surprisingly vital for several reasons. Let's look at why having this information is handy:

  • Security and updates: Newer operating system versions often contain important safety updates to address problems that hackers may create. Knowing your version allows you to guarantee that your system is up-to-date and safe.
  • Software compatibility: Certain software programs are only compatible with specific operating system versions. Knowing yours avoids connection issues and guarantees that you can download and operate the software you require.
  • Troubleshooting: If you encounter any challenges or problems, knowing your operating system version might help you troubleshoot. Many online resources and forums organize remedies by OS version, making it easy to find useful fixes.
  • New features: Upgrades frequently include interesting new features. Knowing your version allows you to determine whether you're missing out on any cool features that your operating system has to offer.

Knowing how to find your OS version using the command line is an easy way to get the correct version without going through menus. Second, the command line can provide additional information, such as the service pack number, which is useful for troubleshooting or program compatibility. There are several commands that you can use for Windows:

Using systeminfo Command

It is very easy! We can use a Command Prompt to find the Windows version:

  1. Open the Command Prompt: To open it, press the Windows key and the letter "R" on your keyboard at the same time. A small box will appear. Type "cmd" (without the quotes) and hit "OK."
  2. Enter the systeminfo command: This command shows a lot of information, so we'll use another tool to filter it down.  Type the following command and press Enter:

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

Example:

For Windows 7:

Note: The info you see might look a little different if you're using Windows 7 with Service Pack 1 (SP1). Don't worry, it still tells you what you need to know!

This fancy code might look scary, but it's just a way to ask for specific details from the big pile of information "systeminfo" gives us.

For advanced users, you can use a simpler search term "OS" in the "findstr" command. This might show more information, like it does for Windows Server 2008 (shown below).  However, this specific command won't work on Windows 7 systems.

Using winver Command

Check OS Version with Command Line is possible using another command. Using this built-in `winver` command is very easy:

  1. Open the Run dialog: Press the Windows key and the letter "R" on your keyboard simultaneously. This opens the command box.
  2. Type the simple command: In the box, type `winver` (without quotes) and press Enter.

A window will emerge, displaying your Windows version and other information such as your operating system name and build number. Believe me! You can`t find any easier way to Find OS Version with Command Line in Windows. It is ideal for anyone who wants to know their Windows version right away.

Using wmic Command

While `winver` is a quick and easy option, the `wmic` command offers more control and is useful for scripting or automation. Here we tell you how to find your OS version with `wmic`:

Open Command Prompt: Press the Windows key and type "cmd" (without quotes). Right-click on "Command Prompt" and select "Run as administrator" (important for `wmic` to work properly).

Type the command: Type the following command and press Enter:

wmic os get Caption, Version

This will display two pieces of information:

  • Caption: This tells you the name of your operating system (e.g., Microsoft Windows 10 Pro).
  • Version: This is the major version number of your Windows installation (e.g., 10.0.19044.1862).

If you want even more details, including the build number, you can use this command:

wmic os get Caption, BuildNumber

This will display:

  • Caption: Same as before, the OS name.
  • BuildNumber: This is a unique identifier for your specific Windows installation (e.g., 19044).

Remember: You have to run the command prompt as administrator. If not, this command won`t work correctly.

You can find macOS version using command line with 2 methods. Continue reading if you want to know how:

Using sw_vers

We recommend this method! Because it's specifically designed to show details about your macOS version. Follow these steps:

  1. Open Terminal:  Go to "Applications" > "Utilities" and launch "Terminal."
  2. Type the command: Enter the following command and press Enter:

sw_vers

Using this command, you can see the following details about your macOS version, including:

  1. ProductVersion: This is the major and minor version number (e.g., 13.4).
  2. ProductName: This tells you the specific macOS name (e.g., macOS Monterey).
  3. BuildVersion: This is a more detailed identifier for your specific installation.

Using system_profiler

While not as focused, this command can also display your macOS version along with other system information:

Open Terminal: Same as before, launch "Terminal" from "Applications" > "Utilities".

Get version with branding: Use the following command and press Enter:

system_profiler SPSoftwareDataType

This command shows the macOS version with proper branding (e.g., macOS Monterey 13.4).

Knowing how to find your Linux version via the command line is valuable for any user. When compared to navigating menus, it is a faster and more efficient way of getting accurate information. Again, there are multiple commands that you can use:

Using lsb_release Command

Follow these steps to Check OS Version with Command Line using this command:

  • Open the Terminal (Linux): The first step is to open the terminal application, a secret code room for your computer! also known as the Linux bash shell. This is where you'll type commands to interact with your system.

📝 Ready to become a Bash pro? Check out our comprehensive Bash Scripting Cheat Sheet for all the commands you need!

Note: If you're working on a remote server, you can use a tool called "ssh" to connect securely.  Just type `ssh username@server_address` (replacing "username" with your login and "server_address" with the server's info) and press Enter.)

  • Enter the command: Now that you're in the terminal, it's time to find your Linux version! you can use the command below:

cat /etc/os-releaselsb_release –ahostnamectl

Using uname –r

This one is a quicker option if you just need the version number:

uname –r

After entering the command, remember to press Enter. You'll see your Linux version displayed, ready for you to copy or reference.

Check OS Version with Command Line in Linux distributions

Checking your Linux OS version with the command line is an easier and quicker way to identify your specific version than going through menus. This information is essential for software compatibility; some programs will only work with specific versions. Additionally, debugging problems becomes easier because internet solutions typically mention specific versions. There are two main ways to check your Linux version with the command line:

Using cat-release commands

This command is the best option because it reads a file containing information about your Linux distribution and version. This method works with a variety of distributions, including CentOS and Ubuntu. The command is:

To see your Linux distribution and its major release version, use the following command:

cat /ets/os-release

For Ubuntu users seeking the full-release version (including minor and point releases), use this command instead:

cat /etc/centos-release

The result will include your operating system name, major release version, and possibly further information.

Using hostnamectl command

The previous commands focus specifically on the version. But if you want more information about your system, you can use another command named hostnamectl. This command queries various files like `/etc/os-release` and displays information like the hostname and kernel version in addition to the OS version itself. Just simply type it:

hostnamectl

Conclusion

Sometimes you have to know the operating system version! And Find OS Version with Command Line is the most powerful and fast method to uncover it. Whether you're using Windows, macOS, or Linux, this blog post has prepared you with the essential commands to unveil your OS's identity. So, the next time you need to determine your operating system version, don't be afraid to open the command line and use these strong commands! This newfound understanding could well be your covert tool for managing the world of technology.

Use the `winver` command for a quick and easy view. Alternatively, use `systeminfo | findstr /B /C:"OS Name" /C:"OS Version"` for more details.

The method depends on your operating system: Windows: Use winver in Command Prompt (CMD). macOS: Use sw_vers in Terminal. Linux: Use cat /etc/os-release or hostnamectl in Terminal.

Windows: winver macOS: sw_vers Linux: cat /etc/os-release (or cat /etc/lsb-release for Ubuntu's full version)

For macOS & Linux use the commands mentioned above (sw_vers for macOS, cat /etc/os-release or hostnamectl for Linux) in your respective Terminal applications.

Lisa P

Lisa P

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.

user monovm

Jerad Lang

2024, Aug, 24

This blog post is super helpful! Knowing your OS version is crucial for security, software compatibility, troubleshooting, and accessing new features. The detailed instructions for Windows, macOS, and Linux make it easy, even if you're not a tech expert. I especially like the emphasis on command line methods—they're quick and efficient. Thanks for providing such comprehensive guidance!