Linux Shell Script To Collect Linux System Information

May 12, 2013 | By
| Reply More

Shell script that take info about linux system like logged users, uptime, load average, free memory, disk usage. Script helps to see all info about system in a second. Administrator can modify the script bit ,if it requires to find system information from multiple server. Script run commands w, uname, uptime, free and df. From the uptime command script take load average.

#!/bin/bash

#clear console
clear

#just echo welcome messages
echo "This is information provided by $0 . Program starts now."

echo "Hello, $USER"

echo

#print today's date
echo "Today's date is `date`, this is week `date +"%V"`."

echo

#list of currently loged user via w command.
echo "These users are currently connected:"

w | cut -d " " -f 1 - | grep -v USER | sort -u

echo

#info about system with command uname and keys -m and -s
echo "This is `uname -s` running on a `uname -m` processor."

echo

#info about uptime, using uptime command
echo "This is the uptime information:"

uptime

echo

#info about free memory via free command
echo "Free memory:"

free

echo

#info about disk usage
echo "Disk usage:"

df -kh

echo

Output

Below is the script output.

This is information provided by ./system_info.sh . Program starts now.

Hello, yevhen

Today's date is Sunday, March 3 2013 22:31:43 +0200, this is week 09.

These users are currently connected:

yevhen

This is Linux running on a i686 processor.

This is the uptime information:

22:31:43 up 1:24, 2 users, load average: 0.45, 0.18, 0.07

Free memory:

total used free shared buffers cached

Mem: 3374792 1589476 1785316 0 96720 725652

-/+ buffers/cache: 767104 2607688

Swap: 4192924 0 4192924

Disk usage:

Filesystem Size Used Avail Use% mounted
/dev/sda1 42G 5,5G 35G 14% /

tmpfs 1,7G 0 1,7G 0% /lib/init/rw

udev 1,7G 168K 1,7G 1% /dev

tmpfs 1,7G 160K 1,7G 1% /dev/shm

/dev/sda6 184G 26G 149G 15% /home

shell script mysql backup

Filed Under : SHELL SCRIPTS

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.