Just execute lsb_release -a
.
On Debian:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux testing (stretch)
Release: testing
Codename: stretch
On Ubuntu:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
In case when you don't have lsb_release
installed you may want to try some guessing, for example, there is a file /etc/issue
that often contains distribution name. For example, on ubuntu:
$ cat /etc/issue
Ubuntu 12.04.5 LTS \n \l
Don't use file /etc/debian_version
because its contents do not match distribution name!
Note that this will also work on non-Debian-family distributions like Fedora, RHEL, or openSUSE — but that lsb_release
may not be installed.