Thursday, January 9, 2025
HomeComputer ScienceCheck OS Version in Linux

Check OS Version in Linux

To check the OS version in Linux, you can use a variety of commands depending on your needs. Below are the most commonly used methods:

1. Using cat Command (OS Release Files)

Most Linux distributions store their version information in files like /etc/os-release or /etc/*-release.

Command:

cat /etc/os-release

Output Example:

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
VERSION_ID="20.04"

2. Using lsb_release Command

If your Linux distribution supports the lsb_release tool, it provides detailed information about the OS.

Command:

lsb_release -a

Output Example:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

3. Using hostnamectl Command

This command works on systems using systemd and gives basic information about the system, including the OS version.

See also  Difference Between Core and Processor (CPU)

Command:

hostnamectl

Output Example:

   Static hostname: linux-server
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 1234567890abcdef
           Boot ID: abcdef1234567890
  Operating System: Ubuntu 20.04.6 LTS
            Kernel: Linux 5.4.0-132-generic
      Architecture: x86-64

4. Using uname Command

The uname command shows kernel and system information, but it doesn’t provide the full OS version.

Command:

uname -a

Output Example:

Linux linux-server 5.4.0-132-generic #148-Ubuntu SMP Fri Dec 9 06:49:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

For Kernel-Only Information:

uname -r

5. Using /etc/issue File

The /etc/issue file often contains a simple description of the OS.

See also  How Does a Computer Work?

Command:

cat /etc/issue

Output Example:

Ubuntu 20.04.6 LTS \n \l

6. Graphical Interface (GUI) Method

If you are using a Linux desktop environment, follow these steps:

  1. Open Settings or System Information.
  2. Look for the “About” or “Details” section.
  3. The OS version should be listed there.

Summary of Commands:

Command Purpose
cat /etc/os-release Displays detailed OS version info.
lsb_release -a Provides Linux Standard Base info.
hostnamectl Shows OS, kernel, and architecture.
uname -a Shows kernel and system info.
cat /etc/issue Displays basic OS info.
See also  Why is my monitor screen slowly turning white, and how can I fix it?"

Use Case-Specific Recommendation:

  • For detailed OS info, use: cat /etc/os-release.
  • For kernel-related info, use: uname -r.

Let me know if you need further assistance!

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x