Locate large files on Linux

Show size of directories. The -h option prints the size in human readable format.

du -h --max=1 ./

We can use sort and tail to filter and only show the 10 largest files and directories. The -a option shows all files and directories.

du -ah ./ | sort -h | tail -n10

We can use the find command to show all files over xMB. In this case 100MB

fine . -type f -size +100M -print

https://linuxhandbook.com/find-biggest-files-linux
https://linuxize.com/post/find-large-files-in-linux/

Delete files older than x days – Linux


You can use find command to find and delete files older than the specified days. In this case 30.

find /backup/* -mtime +30 -exec rm {} \;

Non recursive example. The -prune option should limit find to only look for files in the /backup directory. So it won’t check any subdirectories.

find /backup/* -prune -mtime +30 -exec rm {} \;