GNU/Linux Detecting Linux distribution name and version Detect what debian-based distribution you are working in

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.



Got any GNU/Linux Question?