GNU Linux bash - get distribution OS version

this might sound trivial, but there are multiple approaches:

# for (theoretically every) Debian, but not every Debian based system:
<span style="color: #00ffff;">cat /etc/debian_version</span> 
11.3

# for Debian 10 and prior
<span style="color: #00ffff;">hostnamectl|grep Op</span>
  Operating System: Debian GNU/Linux 10 (buster)

# for Debian 11 and higher
<span style="color: #00ffff;">lsb_release -d</span>
Description:    Debian GNU/Linux 11 (bullseye)

# get kernel version (sometimes also includes hints to the distribution)
<span style="color: #00ffff;">uname -a</span>
Linux hostname 5.4.106-1-pve #1 SMP PVE 5.4.106-1 (Fri, 19 Mar 2021 11:08:47 +0100) x86_64 GNU/Linux

# yes Debian is running conservative mode on kernel updates
# it has it's pros and cons
<span style="color: #00ffff;">uname -a</span>
Linux hostname 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64 GNU/Linux

#linux #gnu #gnulinux #opensource #administration #sysops

Originally posted at: https://dwaves.de/2022/06/03/gnu-linux-bash-get-distribution-os-version/

There are no comments yet.