A Bash Script to Detect OS Info

A Bash Script to Detect OS Info


#!/bin/bash
### Getting OS Information
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DIST=$DISTRIB_ID
DIST_VER=$DISTRIB_RELEASE
else
DIST="Unknown"
DIST_VER="Unknown"
fi
if [ -f /etc/debian_version ]; then
OS="Debian"
VER=$(cat /etc/debian_version)
elif [ -f /etc/redhat-release ]; then
OS="Red Hat"
VER=$(cat /etc/redhat-release)
elif [ -f /etc/SuSE-release ]; then
OS="SuSE"
VER=$(cat /etc/SuSE-release)
else
OS=$(uname -s)
VER=$(uname -r)
fi
  • 7 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

Compile and build Apache + MySQL + PHP from the source [cite]

This is a complete working solution to build Apache (httpd-2.2.25), MySQL (MySQL-5.6.14) and PHP...

Using vi Editor

Vi is the one of the mostly used editor in Linux via terminal. In most cases where Linux is used...

Installing MS SQL Module to PHP on DirectAdmin [cite]

If you need to connect to an MS Sql Server remotely from your DirectAdmin server via php, you...

Firewall Settings With IpTables on CentOS and RedHat [cite]

Here on this article we’ll discuss some basic methods to quickly apply to the iptables...

PHP : Convert/Replace Short Open Tags

Using short open tags, such as <? on your PHP code is not so clever. Other than the debate...