Which Command Is Used To Display The Operating System?

Learn via video courses
Topics Covered

The command used to display the name of operating system:

  1. Linux based OS:

    • uname -a
    • uname -r
    • cat /etc/os-release
    • lsb_release -a
    • hostnamectl
  2. Windows:

    • systeminfo
  3. macOS/UNIX:

    • uname -a
    • sw_vers

Linux based operating systems

To know the name of the operating system, open the terminal using Ctrl+Alt+T or by selecting it from the application menu.

Now, in the terminal window, use any of the following commands to know the name of your operating system:

Command 1: Just the name of the operating system

Output:

Here you can see the name of the operating system ("Ubuntu") along with the processor architecture present on which the OS is running, that is x86_64. The output also shows the timestamp as to when the command was executed.

There are a few variations of this command:

Command 2: Getting just the kernel version

Output:

More flags for this uname command can be found using the following command:

Some other commands that can be used to display the name of the operating system in Linux are:

Command 3:

Output:

The cat command is used to display the contents of any file that is given as arguement. Here, the file /etc/os-release contains all this information, which is presented in the terminal window.

Command 4:

Output:

Please note that it is possible that lsb_release might not be installed on your Linux system by default. Hence, to use this command, install lsb_release prior to using it.

Command 5:

Output:

Please note that Machine ID and Boot ID are hidden for security purposes in the above output, but they will be displayed on your command line.

Windows operating system

To display the name of the operating system, open the command prompt and enter the following command:

This command will give multiple lines of output in the command prompt. Only two of those lines (2nd and 3rd line) are important for us right now:

Output:

UNIX / macOS

Since macOS is built upon UNIX, the same command will work on both the systems.

Use the following commands in the terminal:

Command 1:

Output:

Darwin here refers to the base kernel used by macOS.

Command 2:

Output:

Learn More About Operating Systems

Read article to learn more about operating systems. What is Operating System?

Conclusion

We learned which command is used to display The Operating System Name:

  1. Linux based OS:

    • uname -a
    • uname -r
    • cat /etc/os-release
    • lsb_release -a
    • hostnamectl
  2. Windows:

    • systeminfo
  3. macOS/UNIX:

    • uname -a
    • sw_vers