This command will list all open files, sort them with awk and list the biggest space hogging files.
lsof / | awk '{if($7 > 1048576) print $7/1048576 "MB" " " $9 }' | sort -n -u | tail |
Here is example output of this file on my system. This is a good way to get a picture of what open files are taking up disk space. This is sorted from smallest to largest.
jason@debian:~/Downloads$ lsof / | awk '{if($7 > 1048576) print $7/1048576 "MB" " " $9 }' | sort -n -u | tail 1.53322MB /usr/lib/locale/locale-archive 1.61442MB /usr/lib/x86_64-linux-gnu/libgiomm-2.4.so.1.3.0 1.65765MB /lib/x86_64-linux-gnu/libc-2.19.so 1.8548MB /usr/bin/caja 2.06578MB /usr/lib/x86_64-linux-gnu/libicui18n.so.52.1 2.17364MB /usr/lib/x86_64-linux-gnu/libpangomm-1.4.so.1.0.30 4.29156MB /usr/lib/x86_64-linux-gnu/libgtkmm-2.4.so.1.1.0 4.29343MB /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.25 6.70585MB /usr/lib/x86_64-linux-gnu/libgtk-3.so.0.1400.5 22.4236MB /usr/lib/x86_64-linux-gnu/libicudata.so.52.1 |
Another way is to install the ncdu package and then run this in the directory to see what the largest file is.
The du command can list files and show the largest file(s) in the directory. This solution will sort all files by size.
jason@debian:~/Downloads$ du -hs * | sort -h 460K paper-gtk-theme_2.1+r265~daily~ubuntu16.04.1_all.deb 3.6M Bluecurve-Phenix.tar.gz 16M macOS Dark v2.2.zip 16M macOS Sierra v1.0.zip 40M paper-icon-theme_1.4+r674~daily~ubuntu16.04.1_all.deb </code> This version of the command will output file-sizes in kilobytes. <pre lang="bash"> jason@debian:~/Downloads$ du -BK * | sort -h 460K paper-gtk-theme_2.1+r265~daily~ubuntu16.04.1_all.deb 3632K Bluecurve-Phenix.tar.gz 15416K macOS Sierra v1.0.zip 15980K macOS Dark v2.2.zip 39952K paper-icon-theme_1.4+r674~daily~ubuntu16.04.1_all.deb |
The example here will sort the output of du to have largest files first.
jason@debian:~/Downloads$ du -hs * | perl -e 'sub h{%h=(K=>10,M=>20,G=>30);($n,$u)=shift=~/([0-9.]+)(\D)/; return $n*2**$h{$u}}print sort{h($b)<=>h($a)}<>;' 40M paper-icon-theme_1.4+r674~daily~ubuntu16.04.1_all.deb 16M macOS Dark v2.2.zip 16M macOS Sierra v1.0.zip 3.6M Bluecurve-Phenix.tar.gz 460K paper-gtk-theme_2.1+r265~daily~ubuntu16.04.1_all.deb |