Checking Hard Disk Usage in Linux
As usual I always try to learn more and more SSH tricks, Today I learned how to check hard disk usage in Linux based server. Here are few steps to follow.
Once you are connected to the server via SSH, run the following command:
# df -h

This will output the usage of each partition in the server. To list the size of a specific directory, run the following command:
# du -sh /home/
If you want to list all the subdirectory sizes under /home, run the following command:
# du -sh /home/*
The output of the ‘df’ command will show you overall disk usage. To find out how much space a give directory is used us the ‘du -s ‘ command.
No related posts.
Hi,
Also in the same idea. Some time it’s interesting to know how busy the HardDrive is.
Under AIX platform i’m using topas. But it’s not esily available on all distro, so I use ‘atop’.
Pressing ‘d’ key, will display a list of process ordered by the disk usage.
A small script for getting alert email if some partition reaches some threshold.
————
#!/bin/sh
#
mailid=”example@example.com”
thres=75
df -H | awk ‘!/^Filesystem|tmpfs|cdrom/ { gsub(/\%/,”",$5); print $5,$1}’ | while read line
do
echo $line
eval $(echo “$line” | awk ‘{print “percent=”$1″;parti=”$2}’)
[ $percent -ge $thres ] && echo “Running out of space \”$parti ($percent%)\” on $(hostname) as on $(date)” | mail -s “Alert: Almost out of disk space $percent%” $mailid
done
——–
//Jadu, unstableme.blogspot.com