There are multiple ways to get the Debian version name, commonly known as codename.
/etc/os-release file
/etc/os-release file can only be found on newer version Debian running systemd. It contains identification data of the operating system.
cat /etc/os-release # PRETTY_NAME="Debian GNU/Linux 9 (stretch)" # NAME="Debian GNU/Linux" # VERSION_ID="9" # VERSION="9 (stretch)" # VERSION_CODENAME=stretch # ID=debian # HOME_URL="https://www.debian.org/" # SUPPORT_URL="https://www.debian.org/support" # BUG_REPORT_URL="https://bugs.debian.org/"
hostnamectl
hostnamectl command is part of the systemd package. By default, Debian comes with systemd package installed. It is usually used to set hostname but it does also display Debian version name.
hostnamectl # Static hostname: test # Icon name: computer-vm # Chassis: vm # Machine ID: 319e0cb611544dbeb32cf13de952670c # Boot ID: ecc43c94a0534d108f5a1dafc2f9343e # Virtualization: oracle # Operating System: Debian GNU/Linux 9 (stretch) # Kernel: Linux 4.19.0-0.bpo.6-amd64 # Architecture: x86-64
lsb_release
lsb_release command displays Linux Standard Base(LSB) information about the Linux distribution. However, you need to explicitly install lsb-release package to get this utility.
lsb_release -a # No LSB modules are available. # Distributor ID: Debian # Description: Debian GNU/Linux 9.12 (stretch) # Release: 9.12 # Codename: stretch