How to find the largest files in Linux / Unix

Share it:

This post will be helpful for finding the top largest files in linux box.

du & find  commands are used to find the top largest files.

First CD to the desired location and type the below command  in terminal for finding the largest files

Command : du -hs * | sort -rh

 -h is for displaying the output in human readable form
 -s is for displaying the total
 -r is for sort values in reverse

[root@host-7-81 /]#  du -hs * | sort -rh
3.7G    usr
153M    var
109M    boot
29M     etc
4.7M    run
52K     root
48K     tmp
12K     home
0       sys
0       srv
0       sbin
0       proc
0       opt
0       mnt
0       media
0       lib64
0       lib
0       dev
0       bin

Another way to find the largest file is by using the find command
Command : find . -type f -exec du -sh {} + | sort -rh | head -n 5

[root@host-7-81 /]# find . -type f -exec du -sh {} + | sort -rh | head -n 5
115M    ./usr/share/icons/HighContrast/icon-theme.cache
102M    ./usr/lib/locale/locale-archive
68M     ./usr/share/icons/gnome/icon-theme.cache
66M     ./var/lib/rpm/Packages
65M     ./usr/lib/jvm/java-1.7.0-openjdk-
Share it:

Post A Comment: