Linux find large files

How do you find large files or directories on your disk in freebsd, unix, linux ?
Linux find large files examples; find large files on your disk in *nix.

All *nix systems

List total size of each directory/file at current path level

du -sk * | sort -rn | head

Example output:

[[email protected] /]# du -sk * | sort -rn | head
20089940    total
4628944 root
2102076 usr
723940  opt
493228  var
211744  lib
196708  2012-09-28--00-00
183804  2012-09-15--00-00
174968  2012-09-27--00-00
173756  2012-09-21--00-00
[[email protected] /]# 

Redhat/CentOS

Human Readable, List largest 20 files on disk

FS='./'; resize; clear; echo "== Server Time: =="; date; echo -e "\n== Hostname: =="; hostname; echo -e "\n== Filesystem Information: =="; df -h ${FS} ; echo -e "\n== Largest Directories: =="; du -hcx --max-depth=2 ${FS} 2>/dev/null | grep -P '^([0-9]\.*)*G(?!.*(\btotal\b|\./$))' | sort -rnk1,1 | head -10 | column -t; echo -e "\n== Largest Files: =="; find ${FS} -mount -ignore_readdir_race -type f -exec du {} + 2>&1 | sort -rnk1,1 | head -10 | awk 'BEGIN{ CONVFMT="%.2f"; }{ $1=( $1 / 1024 )"M"; print; }' | column -t; echo -e "\n== Largest Files Older Than 30 Days: =="; find ${FS} -mount -ignore_readdir_race -type f -mtime +30 -exec du {} + 2>&1 | sort -rnk1,1 | head -10 | awk 'BEGIN{ CONVFMT="%.2f"; }{ $1=( $1 / 1024 )"M"; print; }' | column -t;

Find files over 50MB

find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Awesome View

FS='./';resize;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}'

Commands Compatible with almost all Unix/Linux Distros

Find large files in /

cd /
du -sh *

return all files over 1MB

find . -type f -size +1024 -exec ls -ahl {} \;

return all files over 100MB

find . -type f -size +102400 -exec ls -ahl {} \;

return all files over 300MB

find . -type f -size +307200 -exec ls -ahl {} \;

On Ubuntu

find files over 100MB

find / -type f -size +100000k -exec ls -lh {} \;

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>