Categories
Linux Commands

How to Find the Largest Files on the Linux System

Linux has several excellent features to check and verify which directory consumes disk space. It is good to check the system regularly to free up disk space as a Linux user quickly.

It is essential because the system drive may collect huge unnecessary files and take a lot of space. Log files and backup files can take up a lot of disk space on the Linux systems. Read our guide if you also want to learn how to find the largest files on a Linux system. This guide describes how to check the largest files on Linux.

How to Find the Largest Files on Linux System

First, let’s check the largest files and folders present in your Linux. Run the following command:

$ sudo du -a /home | sort -n -r | head -n 10

How to Find the Largest Files on the Linux System

Here are some details about the previous command:

Commands Description

Du command
Calculate the disk space and its usage

Sort command
Sorts the lines of the available text files

-a command
Displays all directories and files

Head command
Shows the output of the first parts of all files

-n command
Compares according to the string numerical value

-r command
Reverses the results of the comparison

-n command
Displays the first n number of files in the output

The number 10 in the previous command shows the top 10 largest files available on Linux.

To get info about the largest files in a specific directory, then run the following command:

$ sudo du -a | sort -n -r | head -n 5

How to Find the Largest Files on the Linux System

You can use the Find command for displaying the biggest size of the files, so run the following command:

How to Find the Largest Files on the Linux System

If you want to find the biggest file in a specific directory, either you can type the path in the command or select that directory as current in the termina, as shown below:

How to Find the Largest Files on the Linux System

Or

find /home -type f -printf "%s %p\n" | sort -rn | head -n 5

How to Find the Largest Files on the Linux System

As you can see in the previous image, the command provides a brief info about the largest file available in the Downloads directory.

Conclusion

Evaluating the highest space-consuming files can help you find and delete the unnecessary files to clear the disk space. We have explained the easiest commands to find the largest files on Linux. You can use the information provided in this article according to the requirements and needs for these commands which differs according to the conditions. We hope you found this article helpful. Check the other Linux Hint articles for more tips and tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *