How to check Linux distribution (CentOS, Ubuntu, Redhat, ...) using a command ?


To check on which GNU/Linux distirbutions you are currently working on, a solution is to use the following command:

hostnamectl

which will returns for example:

Static hostname: ubuntu-**********
Icon name: computer-vm
Chassis: vm
Machine ID: **********
Boot ID: ***********
Virtualization: kvm
Operating System: Ubuntu 16.04.3 LTS
Kernel: Linux 4.4.0-116-generic
Architecture: x86-64

Here we can see that the operating system is Ubuntu.

Reference