How to get Linux version from command line?

Getting Linux Version from Command Line

The Linux operating system is known for its flexibility and customizability, but one of its most fundamental aspects is the ability to retrieve information about the system’s version and configuration. In this article, we will explore how to get Linux version from the command line.

Step 1: Open a Terminal

To start, you need to open a terminal on your Linux system. You can do this by searching for "Terminal" in your system’s application menu or by using the command gnome-terminal or xfce4-terminal (depending on your Linux distribution). Once you have opened a terminal, you will see a command prompt where you can type commands.

Step 2: Type lsb_release -a

The first command you can use to get Linux version from the command line is lsb_release -a. This command will display information about the Linux distribution, including the version, release date, and distribution name.

  • Example Output:
    Linux 5.15.0-42-generic #46-Ubuntu SMP Tue Jul 10 12:34:56 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    In this example, the output shows the Linux distribution name, version, release date, and distribution name.

Step 3: Type uname -a

The second command you can use to get Linux version from the command line is uname -a. This command will display information about the system’s architecture, operating system, and kernel version.

  • Example Output:
    Linux 5.15.0-42-generic #46-Ubuntu SMP Tue Jul 10 12:34:56 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

    In this example, the output shows the system’s architecture, operating system, and kernel version.

Step 4: Type cat /etc/os-release

The third command you can use to get Linux version from the command line is cat /etc/os-release. This command will display information about the Linux distribution, including the version, release date, and distribution name.

  • Example Output:
    NAME=Ubuntu
    VERSION_ID=18.04
    VERSION="ubuntu focal"
    ID=ubuntu
    VERSION_CODE=18.04

    In this example, the output shows the Linux distribution name, version, release date, and distribution name.

Step 5: Type cat /etc/os-release | grep VERSION

The fourth command you can use to get Linux version from the command line is cat /etc/os-release | grep VERSION. This command will display the version number of the Linux distribution.

  • Example Output:
    Ubuntu focal

    In this example, the output shows the version number of the Linux distribution.

Step 6: Type cat /etc/os-release | grep ID

The fifth command you can use to get Linux version from the command line is cat /etc/os-release | grep ID. This command will display the distribution name.

  • Example Output:
    Ubuntu

    In this example, the output shows the distribution name.

Step 7: Type cat /etc/os-release | grep VERSION_ID

The sixth command you can use to get Linux version from the command line is cat /etc/os-release | grep VERSION_ID. This command will display the version ID of the Linux distribution.

  • Example Output:
    18.04

    In this example, the output shows the version ID of the Linux distribution.

Step 8: Type cat /etc/os-release | grep VERSION_CODE

The seventh command you can use to get Linux version from the command line is cat /etc/os-release | grep VERSION_CODE. This command will display the version code of the Linux distribution.

  • Example Output:
    18.04

    In this example, the output shows the version code of the Linux distribution.

Conclusion

In this article, we have explored how to get Linux version from the command line. We have used several commands to retrieve information about the Linux distribution, including lsb_release -a, uname -a, cat /etc/os-release, and cat /etc/os-release | grep VERSION. These commands are essential for troubleshooting and debugging issues on Linux systems.

Tips and Tricks

  • Use lsb_release -a to get detailed information about the Linux distribution.
  • Use uname -a to get information about the system’s architecture, operating system, and kernel version.
  • Use cat /etc/os-release to get information about the Linux distribution, including the version, release date, and distribution name.
  • Use cat /etc/os-release | grep VERSION to get the version number of the Linux distribution.
  • Use cat /etc/os-release | grep ID to get the distribution name.
  • Use cat /etc/os-release | grep VERSION_ID to get the version ID of the Linux distribution.
  • Use cat /etc/os-release | grep VERSION_CODE to get the version code of the Linux distribution.

By following these steps and using these commands, you can easily get Linux version from the command line and troubleshoot issues on your Linux system.

Unlock the Future: Watch Our Essential Tech Videos!


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top