Menu Close

find large files in ubuntu

This command find all files >400MB:

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

And for exclude a folder from this command:

find / -not \( -path /mnt -prune \)  -type f -size +400000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

 

For see the free space you can do:

df -h

 

if you want to see  total size of a folder:

du -sk -h /home/

 

and for listing of all size:

du -h /home/

 

Type the following command at the shell prompt to find out top 10 largest file/directories:

# du -a /var | sort -n -r | head -n 10

Sample outputs:

1008372 /var
313236  /var/www
253964  /var/log
192544  /var/lib
152628  /var/spool
152508  /var/spool/squid
136524  /var/spool/squid/00
95736   /var/log/mrtg.log
74688   /var/log/squid
62544   /var/cache

If you want more human readable output try:

$ cd /path/to/some/where
$ du -hsx * | sort -rh | head -10

Where,

  • du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
  • du command -s option : show only a total for each argument (summary).
  • du command -x option : skip directories on different file systems.
  • sort command -r option : reverse the result of comparisons.
  • sort command -h option : compare human readable numbers. This is GNU sort specific option only.
  • head command -10 OR -n 10 option : show the first 10 lines.
Posted in Linux, News

Leave a Reply

Your email address will not be published. Required fields are marked *