Voici les différentes méthodes :
Méthode n°1 : Fichiers /etc/*-release.
$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.4 LTS"
NAME="Ubuntu"
VERSION="16.04.4 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.4 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
Ubuntu 16.04.4 LTS
==> Méthode n°2 : Commande lsb_release .
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
==> Méthode n°3 : Commande hostnamectl
$ hostnamectl
Static hostname: My-VirtualBox
Icon name: computer-vm
Chassis: vm
Machine ID: 8b7b98b57a954b118f5f8edc0359cde5
Boot ID: d7bc2ea1c813409490604e757cf6483c
Virtualization: oracle
Operating System: Ubuntu 16.04.4 LTS
Kernel: Linux 4.15.0-33-generic
Architecture: x86-64
==> Méthode n°4 : Fichier /etc/issue
$ cat /etc/issue
Ubuntu 16.04.4 LTS \n \l
==> Methode n°5 : Commande uname.
$ uname -a
Linux My-VirtualBox 4.15.0-33-generic #36~16.04.1-Ubuntu SMP Wed Aug 15 17:21:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
==> Methode n°6 : Fichier /proc/version
$ cat /proc/version
Linux version 4.15.0-33-generic (buildd@lgw01-amd64-010) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)) #36~16.04.1-Ubuntu SMP Wed Aug 15 17:21:05 UTC 2018
==> Methode n°6 : Python car il n'y que cela de vrai ... Misère
python -c 'import distro; distro.linux_distribution()'
ou
python -c 'import sys; print(sys.version)'
ou
python -c 'import plateform; platform.linux_distribution()'
Pour information, les mêmes commandes sous une ancienne Fédora 17 :
# cat /etc/*-release
Fedora release 17 (Beefy Miracle)
NAME=Fedora
VERSION="17 (Beefy Miracle)"
ID=fedora
VERSION_ID=17
PRETTY_NAME="Fedora 17 (Beefy Miracle)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:17"
Fedora release 17 (Beefy Miracle)
Fedora release 17 (Beefy Miracle)
# cat /etc/issue
Fedora release 17 (Beefy Miracle)
Kernel \r on an \m (\l)
# uname -a
Linux fedora17-64b.my.com 3.3.4-5.fc17.x86_64 #1 SMP Mon May 7 17:29:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
# cat /proc/version
Linux version 3.3.4-5.fc17.x86_64 (mockbuild@x86-14.phx2.fedoraproject.org) (gcc version 4.7.0 20120504 (Red Hat 4.7.0-4) (GCC) ) #1 SMP Mon May 7 17:29:34 UTC 2012