What Linux Version or Distribution Am I Running?
As a Linux system administrator, there will be times when you need to determine which operating system you are running and which version of that operating system is installed. Many SysOps only ever create a remote connection to servers over SSH, and if the system is not documented or doesn’t have anything valuable in its MOTD screen, finding out what you are using can be tricky if you don’t know how to.
To determine the version of Linux you are running, you can use the command line. Open a terminal window and type one of the following commands:
For Ubuntu and Debian-based distributions:
lsb_release -a command is a Linux command-line utility used to display certain specific information about the Linux distribution you’re currently using. It stands for “Linux Standard Base” and is particularly useful for identifying and providing information about the distribution version, description, codename, and more.
When you run
lsb_release -a in your terminal, it retrieves and presents various details, including:
- Distributor ID: This field identifies the specific Linux distribution you’re using, such as Ubuntu, Debian, CentOS, etc.
- Description: It gives a brief description or name of the Linux distribution along with specific details like the release number, kernel version, and other relevant information.
- Release: This field displays the version number or release number of the Linux distribution.
- Codename: Some Linux distributions have codenames for their releases, and this field provides that specific codename associated with your distribution version.
- ID: This field contains a more specific identifier for the distribution, which can be useful in certain scripts or commands that require detailed identification.
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
lsb_release -a helps users quickly gather essential information about their Linux distribution, which can be crucial for compatibility checks, troubleshooting, or when certain software requires specific versions or distributions to run correctly.
For Red Hat, CentOS, and Fedora-based distributions:
cat /etc/redhat-release # for Red Hat-based distributions
cat /etc/os-release # for recent versions of Linux using systemd
The file is located at
/etc/redhat-release is specific to Red Hat-based Linux distributions. It contains information about the particular version of the Red Hat Enterprise Linux (RHEL) or its derivatives installed on a system. This file serves as a simple way to identify the distribution and version number of the operating system.
When you access the contents of
/etc/redhat-release using a text editor or a command like
cat, you’ll typically see information such as the release name, version number, and possibly other details about the specific Red Hat-based Linux distribution installed on your system.
cat /etc/os-release command in Linux is used to display the content of the
/etc/os-release file in the terminal. This file contains key-value pairs with information about the operating system’s identification, version, and other details related to the distribution.
When you execute
cat /etc/os-release, it will output information about the operating system in a structured format. This might include details like the operating system’s name, version, ID, ID_LIKE, home URL, support URL, bug reporting URL, and more, depending on the specific Linux distribution.
PRETTY_NAME="Ubuntu 22.04.3 LTS"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
Other variants of Linux may use:
These commands will display information about the Linux distribution, including the version number, codename, and other details specific to your system.
Q&A: Deciphering Your Linux System Information
Q1: Why is it important for Linux system administrators to know the version of the operating system they are working with?
Understanding the version of the Linux operating system is crucial for compatibility checks, troubleshooting, and ensuring that software or scripts run seamlessly. Certain applications or commands may have specific requirements tied to the operating system version, making it essential for system administrators to be aware of this information.
Q2: How can Linux administrators determine the version of Ubuntu or Debian-based distributions using the command line?
For Ubuntu and Debian-based distributions, the command
lsb_release -a proves invaluable. It provides details such as Distributor ID, Description, Release, Codename, and more. This information aids administrators in quickly identifying the specific distribution version they are working with.
Q3: What information does the output of
lsb_release -a provide for Ubuntu-based distributions?
The output includes key details like Distributor ID (e.g., Ubuntu), a brief Description of the distribution along with release and kernel version, Release number, and Codename associated with that version. This comprehensive information assists administrators in obtaining a holistic view of their Ubuntu distribution.
Q4: How can system administrators ascertain the version of Red Hat, CentOS, and Fedora-based distributions through the command line?
For Red Hat, CentOS, and Fedora-based distributions, administrators can use the commands
cat /etc/redhat-release or
cat /etc/os-release. The former provides details specific to Red Hat-based distributions, while the latter, applicable to recent Linux versions using systemd, presents information about the operating system in a structured format.
Q5: What information can be extracted from the contents of the
/etc/redhat-release file for Red Hat-based distributions?
/etc/redhat-release file contains information about the release name, version number, and other details specific to Red Hat Enterprise Linux (RHEL) or its derivatives. By accessing this file, administrators can quickly identify the distribution and version installed on their system.
Q6: How does the
cat /etc/os-release command contribute to understanding Linux operating system information?
cat /etc/os-release command displays key-value pairs with information about the operating system’s identification, version, and other details. This includes the operating system’s name, version, ID, ID_LIKE, home URL, support URL, bug reporting URL, and more. It provides a structured overview of the Linux distribution.
Q7: Are there alternative commands for determining Linux distribution information on systems with different configurations?
Yes, for other variants of Linux, the
uname -a command can be employed. This versatile command displays comprehensive information about the Linux distribution, encompassing the version number, codename, and other system-specific details.