What I want is a quick, reliable command to ascertain that the Linux I'm running in is Debian-based. The following command seems to work. It also returns the Debian version:
dpkg -L base-files 2>/dev/null | grep '^/etc/debian_version$' >/dev/null 2>&1 && cat /etc/debian_version
My previous idea was to use dpkg -S /etc/debian_version
to see if it belonged to some package, regardless of name. But dpkg -S
is slow.
I only have a lingering doubt: are there older Debian-derivated distros where my assumption doesn't hold? Is there a better way?