Finding about which OS is running via shell script

Paul Smith paul at mad-scientist.net
Fri Apr 26 20:11:03 UTC 2013


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.





More information about the ubuntu-users mailing list