How to check OS version in Linux command line terminal

How to check OS version in Linux command line terminal

Linux is a free, powerful and open source operating system, it has many different distributions, such as  Debian, Ubuntu, CentOS, RedHat, openSUSEArch, Fedora, and etc. If you are a new Linux user, you will be confused about what version of your Linux machine. Here is the command to help you know your Linux OS version and distribution.

Finding your distribution information by using “lsb_release -a”

The lsb_release command gives Linux Standard Base and distribution-specific information on the Linux terminal, please use to following steps.

Step 1: Open up the terminal window

Step 2: Type in the following command

lsb_release -a

Sample outputs:

root@la:~# lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux 9.5 (stretch)
Release:        9.5
Codename:       stretch

So, the output tells you that your Linux distribution is “Debian”, the OS version is 9.5

Finding Linux OS information by using “/etc/os-release

os-release is a file contains your Linux release information.

Simply type the following command in the terminal:

cat /etc/os-release

Sample outputs:

root@la:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Finding Linux OS information by using “uname  -a

Just type in the following command in the Linux terminal:

uname -a

Sample output:

root@la:~# uname -a
Linux yy.xxxxxxx.com 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64 GNU/Linux

So, let’s analyze the output, Linux means your system is Linux, right? yy.xxxxx.com is the example host address of your Linux system, it is various and depends on your actual computer;  4.9.0-4-amd64 means the kernel version, amd64 means the kernel build for amd64 architecture;  Debian means your Linux distribution called Debian

Finding Linux OS information by using “hostnamectl”

If you want to see what your hostname is, type hostnamectl command in your terminal.

hostnamectl

Sample outputs:

root@la:~# hostnamectl
   Static hostname: yy.xxxxxx.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 1a9848cb913b4xxxxxxxxxxx58850778
           Boot ID: 5cae482324a14xxxxxxxxxxx806b4c76
    Virtualization: kvm
  Operating System: Debian GNU/Linux 9 (stretch)
            Kernel: Linux 4.9.0-4-amd64
      Architecture: x86-64

There is another option: screenfetch

screenfetch is a tool to get your Linux system information from the terminal.

Screenfetch can display the following information:

  • Linux distribution info
  • Linux kernel version
  • uptime
  • the number of installed packages on your system
  • shell name and version
  • screen resolution
  • the name and version of your desktop environment
  • window manager
  • CPU, GPU and RAM info

However, you need install screenfetchin your system first. Here is the quick install tip for screenfetch.

For Debian, Ubuntu, Linux Mint, Deepin, and any Debian based Linux Distro

Open your terminal windows and type in the following command:

sudo apt install screenfetch

Install screenfetch on Fedora

sudo dnf install screenfetch

Install screenfetch on Arch

sudo pacman -S screenfetch

How to use scrrenfetch to get your Linux system information

Simply run the following command in the terminal:

screenfetch

Now, you can see the logo and your Linux system information. Just like the following picture.

screenfetch linux

 

For more helpful tips, please learn more at the home page.

Like this post? Please share this:

2 thoughts on “How to check OS version in Linux command line terminal

Leave a Reply

Your email address will not be published.