Find "n" Largest Files in Linux Mint 20.3 ? - How to ?

We all have multiple files stored on our personal computers. At times, we might want to find the files that are occupying most of the space on our system so that we might move them somewhere else for freeing up the space on our system. 

Here at LinuxAPT, we shall look into finding the "n" largest files in Linux Mint 20.3 where "n" represents the number of the files to be found.


Different ways to find "n" Largest Files in Linux Mint 20.3

1. To find 8 Largest Files in a Particular Folder of Linux Mint 20.3

Here, we want to find out the 8 largest files or directories present within the Home directory of our system. It means that the value of "n" in this case is "8". The command with which we are going to do this is stated below:

$ sudo du –a /home/ | sort –n –r | head –n 8

This command is basically a concatenation of multiple commands that we are going to talk about one by one. First, we have used the "du" command that stands for "disk usage" with the "-a" flag. This command will calculate the size of each file of the specified directory and extract their respective paths. Then, we have provided the path of the directory whose largest files we wanted to list down i.e. "home" in this case. After that, we have used the "sort" command with the "-n" and "-r" flags for sorting the output of the "du" command in descending order i.e. the file with the largest size will appear at the top and so on. Finally, we have used the "head" command with the "-n" flag for specifying the number of files to be found i.e. "8" in this case.

This command will have to compare the sizes of all the files present in the Home directory of our system for finding out the 8 largest files.


2. To find 2 Largest Files in a Particular Folder of Linux Mint 20.3

Here, we want to find the 2 largest files from our Home directory. For doing that, we will be using the exact same command that we have used in our first example. However, we will simply change the value of "n" from "8" to "2" as shown in the command below:

$ sudo du –a /home/ | sort –n –r | head –n 2


[Need help in fixing Linux Mint system issues ? We can help you. ]

This article covers the different ways of finding the "n" largest files in Linux Mint 20.3. In fact, you can replace the value of "n" with any desired integer according to the number of files that you want to find. Moreover, you can also specify the path according to your needs i.e. you can mention the path of any desired directory whose largest files or sub-directories you want to find out.

Related Posts