Search This Blog

Friday, June 18, 2010

How to gather Information about Linux Machine.

With a wide variety of Linux distributions available ,Sometime it becomes very essential to know which OS you are using.

I have listed some important commands to accomplish the task.
Name of distribution
# uname -o
GNU/Linux
Name of kernel version
# uname -r
2.6.9-78.0.0.0.1.ELhugemem
Version of OS only 4 redhat
# cat /etc/redhat-release
Enterprise Linux Enterprise Linux AS release 4 (October Update 7)

lsb_release –a ----------------------Very useful

http://www.linuxquestions.org/questions/linux-newbie-8/which-command-to-use-to-find-name-of-operating-system-764452/#post3732489

Use following program to determine the name of distribution you are using.

function get_distro_name {
if [[ -r '/etc/lsb-release' ]]; then
. /etc/lsb-release
[[ "$DISTRIB_ID" ]] && n="$DISTRIB_ID"
elif [[ -r '/etc/release' ]]; then
n=`head -1 /etc/release | sed 's/ *\([[^0-9]]*\) [0-9].*/\1/'`
elif [[ -r '/etc/arch-release' ]]; then
n="Arch Linux"
elif [[ -r '/etc/debian_version' ]]; then
n='Debian'
elif [[ -r '/etc/gentoo-release' ]]; then
n='Gentoo'
elif [[ -r '/etc/knoppix-version' ]]; then
n='Knoppix'
elif [[ -r '/etc/mandrake-release' ]]; then
n='Mandrake'
elif [[ -r '/etc/pardus-release' ]]; then
n='Pardus'
elif [[ -r '/etc/puppyversion' ]]; then
n='Puppy Linux'
elif [[ -r '/etc/redhat-release' ]]; then
n='Red Hat'
elif [[ -r '/etc/sabayon-release' ]]; then
n='Sabayon'
elif [[ -r '/etc/slackware-version' ]]; then
n='Slackware'
elif [[ -r '/etc/SuSE-release' ]]; then
n='SuSE'
elif [[ -r '/etc/xandros-desktop-version' ]]; then
n='Xandros'
elif [[ -r '/etc/zenwalk-version' ]]; then
n="Zenwalk"
fi
[[ "${n:-}" = '' ]] && \echo "ERROR: Could not determine the distro name" >&2 && \exit 1
echo $n
}
get_distro_name

No comments:

Post a Comment