This question already has an answer here:

I have been writing a shell script that needs to know if the system one is on is, in fact, Debian-based. Now I have seen this question, but its answers weren't so helpful. I am aware of checking /etc/os-release and the output of lsb_release, likewise I know that checking if rpm or dpkg commands exist is another way of checking whether one's distribution is Red Hat or Debian-based, respectively. All these methods have flaws though. There are hundreds of different Debian-based distros (including those based on Ubuntu, which is in itself based on Debian) and checking whether the NAME field in /etc/os-release, or the Distributor ID in the output of lsb_release -a matches any of the hundreds of known Debian-based distributions would take forever. Checking whether the commands dpkg and rpm exist aren't fool-proof either as some people install other distribution's package managers for various different reasons. For example, on my Ubuntu machine I have RPM installed, partly because sometimes I use the Open Build Service's OSC command, which in some cases requires RPM.

So in short I want a simple and fast way of checking (with certainty) whether the distribution my script finds itself on is Debian-based or not. Is this possible?

EDIT: As people seem to be implying, by voting to close this question, that /etc/debian_version is present on all Debian-based systems. Does anyone have proof of this?

marked as duplicate by Stephen Kitt, Satō Katsura, countermode, n.st, Eric Renouf Nov 6 '16 at 14:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I never even referred to /etc/debian_version so I don't see how this could be a duplicate. – Brenton Horne Nov 6 '16 at 8:30
  • Although titled a little differently, Does Linux Mint have /etc/debian_version? provides two reliable solutions to check if a system is indeed Debian-based. It's not a "duplicate" of your question, but it answers your question, which is another possible reason for a "duplicate" close vote. – n.st Nov 6 '16 at 12:52

All Debian derivatives should have /etc/debian_version, which is provided by the essential base-files package. Since it's essential you can rely on it being installed, and therefore the file being present.

I say "should" because there's nothing preventing a derivative from deleting that file, but as far as I'm aware none do. See Does Linux Mint have /etc/debian_version? for more details.

Not the answer you're looking for? Browse other questions tagged or ask your own question.