check system script - July 2012
#!/bin/bash
# purpose: script to check system info; author: john ; July 2012
if [ ! -d ~/bin/LOGS ]
then
/bin/mkdir ~/bin/LOGS
/bin/echo "LOGS directory in ~/bin made"
fi
LOG=~/bin/LOGS/Lab_`date +'%Y%m%d'`.txt ; export LOG
echo "" > $LOG # clear output file
DATE=`date +'%Y%m%d'` ; export DATE
echo "___________________________________________" | tee -a $LOG
echo "### ( hostname is: `uname -n` ) ###" | tee -a $LOG
echo "### (this system uses: `ifconfig -a | grep Bcast | awk '{print $2}' | cut -c 6-20` \
for its IP address with `route | grep default | awk '{print $2}'` as the gateway) ###" | tee -a $LOG
echo "###( these are the nameservers used: `cat /etc/resolv.conf | grep nameserver | awk '{print $2}'` ) ###" | tee -a $LOG
uptime | awk '{print "system up " $3 " " $4 " at " $1 " load avg=" $12$13 }' | tee -a $LOG
echo "___________________________________________" | tee -a $LOG
echo "### Disk Information ####" | tee -a $LOG
fdisk -l /dev/sda | grep sda | tee -a $LOG
df -h | grep -v dev | grep -v tmpfs | grep -v rootfs | tee -a $LOG
du -sh /home/ | tee -a $LOG
du -sh * 2> /dev/null | tee -a $LOG
for x in `ls` ; do echo $x; ls -alR $x 2> /dev/null | wc -l ; done | tee -a $LOG
for x in `ls` ; do echo $x ; \
# /bin/find $x -user root -perm -4000 -print 2> /dev/null | wc -l ; done | tee -a $LOG
/bin/find /etc -user root -perm -4000 -print 2> /dev/null | wc -l ; done | tee -a $LOG
echo "### Usage Information ####" | tee -a $LOG
last | grep reboot | tail -n 1 | tee -a $LOG
last | awk '{print $1}' | sort | uniq | grep -v root | grep -v reboot | grep -v wtmp| tee -a $LOG
|
The Art of Linux System Administration published by O'Reilly Media Study Guide for the LPIC-2 Certification Exams |
![]() Wagoneers FULL SIZE JEEPS JeepMeister "Jeep is America's -Enzo Ferrari MeisterTech Diesels + |
One Page Overview of Linux Commands click for an image of the 5 essential Linux commands An Intro to Linux |
at Midway Auto on SR9 in Snohomish, or at Northland Diesel in Bellingham, WA |