Running out of disk space on a Linux server or desktop can lead to application crashes, failed backups, and a sluggish system. Unlike graphical operating systems that offer visual storage managers, Linux administrators often need to rely on the command line to clean up their hard drives. Learning how to find large files in Linux is an essential troubleshooting skill that will help you identify exactly what is eating up your storage capacity.
In this guide, we will cover the most effective terminal commands to quickly locate massive files and bulky directories across your entire file system.
Using the ‘find’ Command for Specific Files
The find command is the most powerful search tool in the Linux ecosystem. You can use it to filter files based on their exact size, making it perfect for hunting down forgotten ISO images, massive log files, or uncompressed database dumps.
Open your terminal and type the following command to search for any file larger than 100 Megabytes (MB):
sudo find / -type f -size +100M
Breaking Down the Syntax
- sudo: Runs the command with root privileges, ensuring you do not get “Permission Denied” errors when searching system directories.
- /: Instructs the tool to start searching from the root directory (the very top of your file system). If you only want to search your home folder, replace
/with~. - -type f: Tells the tool to only look for files, ignoring directories.
- -size +100M: The crucial filter. It searches for files strictly larger than 100 Megabytes. You can change this to
+1Gfor files over a Gigabyte.
Using the ‘du’ Command for Bulky Directories
Sometimes, your storage problem is not caused by one massive file, but rather thousands of small files hiding in a single folder (like a bloated cache directory). In this scenario, the find command will not help you. Instead, you need to use du (Disk Usage).
To see a readable list of the largest directories on your system, use this combined command string:
sudo du -h / | sort -rh | head -n 20
Breaking Down the Syntax
- du -h /: Calculates the disk usage starting from the root directory. The
-hflag formats the output into “human-readable” sizes (like MB and GB instead of raw bytes). - | (pipe): Takes the output of the first command and feeds it directly into the next command.
- sort -rh: Sorts the list in reverse order (largest to smallest), specifically understanding human-readable numbers.
- head -n 20: Limits the final output to only show the top 20 largest directories, preventing your terminal screen from being flooded with thousands of lines of text.
Frequently Asked Questions
Can I automatically delete the large files I find?
Yes, but you must be extremely careful. You can append the -delete flag to your find command (e.g., find ~/Downloads -type f -size +1G -delete). However, this bypasses the trash bin entirely. If you accidentally delete a critical system file, your Linux machine may not boot.
What is the fastest way to check my total free space?
Before you start searching for files, you should always check your overall disk health by typing df -h. This command instantly prints a summary of all connected drives, showing total size, used space, and available space.
By keeping these two commands in your system administration toolkit, you can quickly resolve “Disk Full” errors and keep your Linux environment running smoothly.