How To Find Large Files Using Command Line In Linux


Table of Contents

Today, we will learn to find large files in Linux with the command-line. We are going to use a command called “find”. It does its job extraordinarily well. Now, Let’s see the working of this command and how to use ‘find’ for finding large files in Linux.

How To Find Large Files Using Command Line In Linux

find’ command

The syntax of this command goes like this :

$ find directory -test pattern

The “directory” should be replaced with the directory path that you want to search for. You can specify multiple directories too.  “Test” means a condition in which the files should match. The most common test we use names. We specify a name and search for the files of the name.

An example of the name test is –

$ find ~ -name foo
find command in linux

This command will search for files named “foo” (case sensitive) in the ~ (home directory of the user). You can also search for multiple directories. For example –

$ find ~ /media/user -name foo

This command will search for the files named “foo” in the home directory of the user as well as in the “/media/user/” path ( usually where all the other partitions are mounted). Note:- Replace the user with your username.

You can use wildcards too for patterns. Just don’t forget to use the double quotes around the pattern or name with wildcards to suppress expansion.​

Now, there is a test called size. This is used to find files on the basis of their sizes. $ find ~ -size 10M This command will show you files that are exactly 10 MB, and I don’t think it will be much useful as people can remember the exact file names. That is why we use –

This command will show all files above 10 MB. You already guessed how to search for large files now. It depends on what size you call large. If you need to use GB, then, simply replace “M” with “G”. ​ $ find ~ -size +3G

find file size in command line in linux

This command will search for files above 3 GB. I know that the meaning of large varies over contexts. For example, large is different for images and movies. Images are around 1 or 2 MB. But videos don’t practically exist around that size. So, combine the size and name tests. ​

$ find ~ -size +10M “*.m4a”
find file size in command line with file format

Replace m4a with any extension of your choice. ​


Now, you can search files with the command line on Linux. Just remember that the command line is very powerful and find command is one of the basic tools. So, you can expect it to be really flexible and robust. find has a lot more options which you can find in its man page. ​

Linux toolsUncategorizedhow-to