Skip to content
Advertisement

Need to get Linux Dist name from different Dists

want to code a script that is for multiple linux distributions. Also want to add commands that check, and if not exist install some packages.. So, need a solution to ckeck Dist name (like Debian or RedHat) to execute the right command for this Dist. I have tryed “lsb_release” but is this working all the follow dists? : Debian / Ubuntu | Red Hat / Fedora / Suse / Cent OS” If yes, any idea where i can get the lsb_release output from all the Dists above?

in Debian I get this from lsb_release -a 2>/dev/null | grep Distributor:

Distributor ID: Debian

at Rasberry, I get this:

Distributor ID: Raspbian

but what about other Distributions?

Advertisement

Answer

Yes, the lsb_release should print the distribution information after installing the required package.

e,g:

On debian based distro:

JavaScript

On RHEL based distro:

JavaScript

or

JavaScript

Alernative method : You can get the distribution information through:

On debian based disto

JavaScript

On RHEL based distro :

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement