Finding the largest files and directories Print
- 21242
FS='/';clear;date;df -h $FS; echo "Largest Directories:"; du -hcx –max-depth=2 $FS 2>/dev/null | grep [0-9]G | sort -grk 1 | head -15 ;echo "Largest Files:"; nice -n 19 find $FS -mount -type f -print0 2>/dev/null| xargs -0 du -k | sort -rnk1| head -n20 |awk '{printf "%8d MB\t%s\n",($1/1024),$NF}'
You’ll need to adjust it, depending on which directory you wish to look within. For example, if you’re looking for a list of the largest files and folders in the /home directory, you’d use:
FS='/home';clear;date;df -h $FS; echo "Largest Directories:"; du -hcx –max-depth=2 $FS 2>/dev/null | grep [0-9]G | sort -grk 1 | head -15 ;echo "Largest Files:"; nice -n 19 find $FS -mount -type f -print0 2>/dev/null| xargs -0 du -k | sort -rnk1| head -n20 |awk '{printf "%8d MB\t%s\n",($1/1024),$NF}'
Was this answer helpful?
Related Articles
Changing the timezone
If you're like us, you'll want your server's timezone to match your local time to make log...
Installing and using iftop
The installation commands are as follows:yum -y install libpcap libpcap-devel ncurses...
Find where a process is running from
You may see a process running and wonder exactly where it's running from. Fortunately, there's a...
Installing and using Strace
Strace is a Linux command that allows you to follow what a process on your server is doing. Let's...
Quickly and easily finding the source of emails in Exim
Ever found yourself in the position where there are hundreds, or perhaps, thousands of emails...