Debian – How to get Debian codename without lsb-release

debianversion

I am trying to create a script that requires me to print the debian codename so that I may echo it into the sources.list file.

I am trying to make this script work across any version of Debian, so I had hoped to set a bash variable of the release codename. This would be simple to do (with lsb_release -c), however our deployment images do not contain lsb_release by default – and with this script being required to fix the sources.list, installing lsb-release with apt-get would not be an option.

I have found numerous ways to get the release number and other info about the system, but cannot find a reliable place to get the codename.

Any ideas would be greatly appreciated!

(OS I am testing this with is Debian Squeeze)

Best Answer

You can use /etc/os-release:

(
  . /etc/os-release
  printf '%s\n' "$VERSION"
)
7 (wheezy)
Related Question