2

I am trying to write a script which works based on the knowledge that each Linux Mint release was based on a particular Ubuntu release.

However, I do not want to install Linux Mint to verify that, but instead let the users of the script test it, if they need it.

Can I rely on the presence of /etc/debian_version, though? I am doing this in order to detect Debian and its derivatives. It works reliably on Debian and Ubuntu, but does Linux Mint have this file?

Note: I am aware of lsb_release and I am using that in order to figure out more details later on. But the existence of /etc/debian_version is a way to make assumptions about certain things before even checking for and invoking lsb_release.

0xC0000022L
  • 16,593

3 Answers3

4

As mentioned in @kirill-a's answer, /etc/debian_version should be present in any Debian derivative.

Another useful approach to find out information on the current Debian-based distribution and its "ancestry" is dpkg-vendor; for instance,

dpkg-vendor --derives-from Debian

should succeed on any Debian derivative (and on Debian itself),

dpkg-vendor --derives-from Ubuntu

should succeed on any Ubuntu derivative (and on Ubuntu itself), etc. A distribution is considered a derivative of itself as well as of its parents, so Ubuntu is a derivative of Ubuntu and of Debian.

dpkg-vendor is shipped in dpkg-dev so that needs to be installed for the command to be available, which reduces the usefulness somewhat.

Stephen Kitt
  • 434,908
  • 1
    Wow, didn't know of that one. However, before your if (and assuming Bash) I'd always do type dpkg-vendor > /dev/null 2>&1 || { echo "No dpkg-dev!"; exit 1; }, which tests for the availability of the program. And it turns out this is part of dpkg-dev which is one of the packages that gets installed via build-essential, but it's not part of a base installation. Still, very cool idea and method. – 0xC0000022L Feb 02 '15 at 08:54
  • 1
    Note that, like /etc/debian_version, that reports information stored in the base-files package which on Mint comes straight from Ubuntu. /etc/lsb-release, /etc/issue... also come from bash-files, but the mintsystem package registers File triggers for them and overwrites them whenever they're modified by another package. – Stéphane Chazelas Feb 02 '15 at 21:46
2

Yes, as in any Ubuntu derivative, this file is present.

enter image description here

kirill-a
  • 2,923
  • Thanks. Well, I know that theoretically that should be the case. My question, however, was whether it is the case on Linux Mint specifically. The well-known problem is that in theory practice and theory are the same; but in practice they often divert. My uncertainty in response to your answer stems from a generic answer to a specific question. – 0xC0000022L Feb 02 '15 at 08:49
  • Awesome, this screenshot is proof enough. Thanks. – 0xC0000022L Feb 02 '15 at 08:50
-3

I'm running Mint 19

$ lsb_release -d 
Description:    Linux Mint 19 Tara

$uname -a
Linux mymc 4.15.0-20-generic #21-Ubuntu SMP ...

$ cat /etc/debian_version
buster/sid

This: cat /etc/debian_version | grep -o '[0-9]'| head -1|sed -e 's/ //' should tell you what version of debian is used, but mint obscured it.

GAD3R
  • 66,769
  • 3
    Sorry, but your answer does not add anything to the existing ones and it doesn't even answer the question (apart from showing that /etc/debian_version is indeed present on your system). – TooTea Nov 02 '18 at 10:11
  • 1
    Your last paragraph is only correct for stable Debian releases; buster/sid is a perfectly valid entry for Debian and derivatives, Mint isn’t obscuring anything. – Stephen Kitt Nov 02 '18 at 16:06