User Tools

Site Tools


largest_files

This is an old revision of the document!


Largest files in file system

Quickly check the log file size:

du -sh /var/log
Quickly check the home directory of a user:
du -sh /home/rack
Show a break down of the system usage:
FS='/';NUMRESULTS=20;resize;clear;date;df -h $FS; echo "Largest Directories:";\
du -x $FS 2>/dev/null| sort -rnk1| head -n $NUMRESULTS| awk '{printf "%d MB %s\n",\
$1/1024,$2}';echo "Largest Files:"; nice -n 19 find $FS -mount -type f -ls \
2>/dev/null| sort -rnk7| head -n $NUMRESULTS|awk '{printf "%d MB\t%s\n",\
($7/1024)/1024,$NF}'

Excluding a specific directory:

Following shows the largest directories excluding /var/lib/mysql

FS='/';NUMRESULTS=20;resize;clear;date;df -h $FS; echo "Largest Directories:";\
du --exclude /var/lib/mysql -x $FS 2>/dev/null| sort -rnk1| head -n $NUMRESULTS| awk '{printf "%d MB %s\n",\
$1/1024,$2}' 

Other Command:

echo -e "\n\nHi, \n\nDiskoverview for $(hostname)\n\n $(df -h) \n\nHere is the list of the largest files: \n" ; find / -type f -not -path "/proc/*" -not -path "/dev/*" -not -path "/sys/*" -size +512000k -exec du -hs {} \;  ;  echo -e  "\n\nAnd here is the list of the largest folders:\n"; du -h / | grep ^[1-9][0-9][0-9.]*G | sort -rn;


INODES

nice -n 19 find / -type d 2>/dev/null -print0 | while IFS= read -rd '' i; do echo $(ls -a "$i" | wc -l) "$i"; done | sort -n -r | head

largest_files.1453979013.txt.gz · Last modified: 2024/05/23 07:26 (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki