There are times when you need to find the largest files in your Linux Terminal. Here are a list of commands that you can use to find out what is bloating your website. Remember that every web page that you have should not load any more than 2 MB maximum.
Use The List Command ls -ls
If you want to see the descending order of the files according to their size, use this command. The largest files will be on top. This is great if you just want to see the largest files in your directory, but it does not show the file size.
View The File Size with the Find Command
To view the file size with the find command, use this. Specifically, what this command does is find any files that are over 100 MB. If it does not find anything, it will return nothing. If it finds them, then it will list the files that are over 100 MB.
find . -type f -size +100M
Find Files Over 10MB
So if you wanted to find files 10 MB and over, use this command.
find . -type f -size +10M
Find Large Files In A Directory
If you wanted to find large files in a directory on Linux, use this command. Notice, we are searching the directory of test in the command below.
find ./test -type f -size +100M