Given a minimal version of a Linux system, how can you know which distribution and which version of the distribution you are working on? This is a vital question. First, you may think about typing in uname -a, but this does not provide all of the information you may need. Luckily, there is a file that almost all distributions have that keeps this valuable data.

get linux version command line

This is the /etc/os-release file. You might guess how it can be viewed because we covered the use of cat command previously. So, you simply do the following and you will happily have what you are looking for.

$ cat /etc/os-release
VERSION="18.04.2 LTS (Bionic Beaver)"
PRETTY_NAME="Ubuntu 18.04.2 LTS"

uname, on the other hand, provides the following system information:

  • -a, –all print all information, in the following order, except omit -p and -i if unknown:
  • -s, –kernel-name print the kernel name
  • -n, –nodename print the network node hostname
  • -r, –kernel-release print the kernel release
  • -v, –kernel-version print the kernel version
  • -m, –machine print the machine hardware name
  • -p, –processor print the processor type (non-portable)
  • -i, –hardware-platform print the hardware platform (non-portable)
  • –version output uname version information and exit
  • -o, –operating-system (mostly outputs GNU/Linux)

Examples of uname usage

$ uname -o                                                                                                    

$ uname -m                                                                                                    

$ uname -r

$ uname -s                                                                                                    

$ uname -a
 Linux cloudstack 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

As you can see above, the distribution and version of the distribution cannot be found using the uname command.

Using lsb_release command

On Debian based Linux distributions, you can use the lsb_release command to print distribution-specific information.

Available options:

-v, --version: Show the version of the LSB against which your current installation is compliant.
-i, --id:  Display the distributor's ID.
-d, --description: Display a description of the currently installed distribution.
-r, --release: Display the release number of the currently installed distribution.
-c, --codename: Display the code name of the currently installed distribution.
-a, --all: Display all of the above information.
-s, --short: Use the short output format for any information displayed.  This format omits the leading header(s).
-h, --help: Show summary of options.

See examples on usage below.

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

$ lsb_release -c
Codename:	buster

$ lsb_release -d
Description:	Debian GNU/Linux 10 (buster)

$ lsb_release -i
Distributor ID:	Debian

Using hostnamectl command

For Linux systems with Systemd init, you can get some system information from hostnamectl command output, like the Operating System, Kernel version and CPU architecture.

[email protected]:~# hostnamectl 
    Static hostname: debian10
          Icon name: computer-vm
            Chassis: vm
         Machine ID: 2e5ced54e5274424b2165b459a18372a
            Boot ID: e21975d65c53409497466bfbce9cc193
     Virtualization: kvm
   Operating System: Debian GNU/Linux 10 (buster)
             Kernel: Linux 4.19.0-5-amd64
       Architecture: x86-64

See the complete list of available options with:

$ hostnamectl  --help
hostnamectl [OPTIONS...] COMMAND ...

Query or change system hostname.

  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[[email protected]]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname

  status                 Show current hostname settings
  set-hostname NAME      Set system hostname
  set-icon-name NAME     Set icon name for host
  set-chassis NAME       Set chassis type for host
  set-deployment NAME    Set deployment environment for host
  set-location NAME      Set location for host

See the hostnamectl(1) man page for details.

Check /etc/issue Content

View content on /etc/issue.

$ cat /etc/issue
Debian GNU/Linux 10 \n \l


Finding the distribution and version of the distribution is as easy as you have found out. We hope it was beneficial and informative.

Also Read:

How To Check CPU Usage/Utilization in Linux system

How To Use Linux find Command To Locate files

How To Set System-Wide Proxy on Ubuntu 18.04 / Debian 10

How to setup Squid proxy on Ubuntu 18.04 / Ubuntu 16.04 / CentOS 7

Grafana behind Nginx and Apache Proxy

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here