Version linux
Il y a beaucoup de "trucs" différents pour obtenir le nom et la version d'une distribution linux. Attention la commande :
uname -a
ne donne que les informations concernant le noyau LINUX mais rien sur la distribution (RedHat, Debian...)
La méthode élégante
Une commande existe et s'appelle lsb_release. Le requête la plus simple est donc:
lsb_release -a
(-a pour all.) Donne la réponse:
$ lsb_release -a LSB Version: :core-3.0-amd64:core-3.0-noarch:graphics-3.0-amd64:graphics-3.0-noarch Distributor ID: RedHatEnterpriseAS Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 4) Release: 4 Codename: NahantUpdate4
Pour un serveur Red Hat d'il y a bien longtemps (2005-2012) :
$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 8.04.1 Release: 8.04 Codename: hardy
Pour mon petit serveur linux chez gandi (en 2010) qui a été remplacé plusieurs fois depuis!
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm
Pour mon Raspberry PI 4 datant de 2025!
La méthode pour Debian
Je ne sais pas bien si elle marche ailleurs mais mon VPS sous Ubuntu et mon Raspberry PI sous "Raspberry PI OS" répondent à cette commande.
hostnamectl
Qui nous donne plein d'infos :
Static hostname: my-host
Icon name: computer
Machine ID: 81376ffffffa84472992ea87118c8dba2
Boot ID: 4cb595d6c08f49e3bcffffff5bc741dd
Operating System: Debian GNU/Linux 12 (bookworm)
Kernel: Linux 6.6.51+rpt-rpi-v8
Architecture: arm64
Ici c'est mon raspberry PI.
Static hostname: vpn-host-000
Icon name: computer-vm
Chassis: vm
Machine ID: ffffff0ee9594f5896ff8141d3074445
Boot ID: 964fd71f9d8d4f1ffffff1acdbcec6ed
Virtualization: xen
Operating System: Ubuntu 20.04.6 LTS
Kernel: Linux 5.4.0-208-generic
Architecture: x86-64
La méthode "raw"
$ cat /etc/issue Ubuntu 9.04 \n \l
Donne moins d'infos est est plus "salle".