Finding about which OS is running via shell script

Gene Heskett gheskett at wdtv.com
Fri Apr 26 22:44:46 UTC 2013


On Friday 26 April 2013 18:44:10 Paul Smith did opine:

> On Fri, 2013-04-26 at 14:04 -0600, JD wrote:
> > On 04/26/2013 01:46 PM, Kevin Wilson wrote:
> > > Hello,
> > > My aim is to right a script that will behave differently
> > > when running it on Fedora or running it on Ubuntu.
> > > Is there a way to know from Bash whether the OS is ubuntu or
> > > Fedora (besides parsing /etc/issue ) ?
> > 
> > A quick way is to run uname
> 
> This is not reliable though.  The only way you can find the distribution
> is if your distribution just happens to set its name in the kernel
> version string when they build their kernel.  There's no standardization
> around this.
> 
> On my CentOS systems, they don't set it at all:
> 
>   $ uname -v
>   #1 SMP Fri Jul 20 01:55:29 UTC 2012
> 
> On my Mint systems, they use Ubuntu's kernel so the kernel says
> "Ubuntu".
> 
> Etc.

You will sometimes find more accurate info by 'cat /etc/issue'.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page: <http://coyoteden.dyndns-free.com:85/gene> is up!
My views 
<http://www.armchairpatriot.com/What%20Has%20America%20Become.shtml>
Where it is a duty to worship the sun it is pretty sure to be a crime to
examine the laws of heat.
		-- Christopher Morley
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
         law-abiding citizens.




More information about the ubuntu-users mailing list