How to Find Most Used Disk Space Directories and Files in Linux

To identify large files that haven’t been accessed in a long time (potential candidates for archival or deletion), combine size and time parameters:
To display the largest folders/files, including the sub-directories, run:
Sometimes you don’t need to see all files ranked by size, but you just want to identify files that exceed a certain threshold, such as files larger than 100MB or 1GB.

Find Largest Directories in Linux Using du Command

find /home/tecmint -type f -empty

du -hs * | sort -rh | head -5

Find Top Directories Sizes in Linux
Find Top Directories’ Sizes in Linux

find -type f -exec du -Sh {} + | sort -rh | head -n 5

Find Top File Sizes in Linux
Find Top File Sizes in Linux

To find all empty files:
If you want to display the biggest file sizes only, then run the following command:

Find Top Directories and Subdirectories by Size

To find large files modified more than a year ago:
du -a | sort -n -r | head -n 5

Find Biggest Directories Only
Find the Biggest Directories Only

find /home/tecmint -type f ( -name “*.mp4” -o -name “*.avi” -o -name “*.mkv” ) -exec du -ch {} + | grep total$

Find and Remove Empty Files and Directories

That’s all for now. Finding the biggest files and folders is no big deal. Even a novice administrator can easily find them. If you find this tutorial useful, please share it on your social networks and support TecMint.
du -a /home | sort -n -r | head -n 5

Find Largest Directories in Linux
Find Largest Directories in Linux

Example: -size +500M finds files larger than 500 megabytes.
find /home -type f -size +50M -atime +180 -exec ls -lh {} ;

As a Linux administrator, you must periodically check which files and folders are consuming more disk space, because it is very necessary to find unnecessary junk and free it up from your hard disk.
find /var/log -type f -name “*.log” -exec du -ch {} + | grep total$

Find Total Space Used by Video Files

find /home -type f -size +1G -exec ls -lh {} ; | awk ‘{ print “: ” }’

find /home/tecmint -type f | sed ‘s/.*.//’ | sort | uniq -c | sort -rn | head -10

Find Total Space Used by Log Files

find /home -type f -size +100M -exec ls -lh {} ; | awk ‘{ print “: ” }’

find /home -type f -size +50M -ctime -7 -exec ls -lh {} ;

First, install ncdu:
find /home -type f -size +10M -size -100M -exec ls -lh {} ; | awk ‘{ print “: ” }’

Exclude Directories from Disk Usage Search

find /home/tecmint -type f -empty -delete

Analyze Disk Usage with ncdu Tool

ncdu /home

find /home/tecmint -type d -empty

To track down large files that were recently created (useful for identifying what’s filling up your disk):
du -Sh | sort -rh | head -5

Find Largest Folder and Sub directories
Find the Largest Folder and Subdirectories

When using the find command with -size option, remember these units:
du -h –exclude=/proc –exclude=/sys –exclude=/dev / | sort -rh | head -n 10

Some of you would like to display the above result in a human-readable format. i.e., you might want to display the largest files in KB, MB, or GB.
find /var/log -type f -size +100M -mtime +365 -exec ls -lh {} ;

Find Disk Usage by File Type (Extension)

If you want to learn more about these commands, then head over to the following articles.

Find Recently Created Large Files in Linux

find /home/tecmint/Downloads/ -type f -exec du -Sh {} + | sort -rh | head -n 5
OR
find /home/tecmint/Downloads/ -type f -printf “%s %pn” | sort -rn | head -n 5

Find Top File Size in Specific Location
Find the Top File Size in a Specific Location

sudo yum install ncdu [On RHEL/CentOS/Fedora]
sudo apt install ncdu [On Debian/Ubuntu]

find /home -type f -not -path “*/node_modules/*” -not -path “*/.cache/*” -exec du -Sh {} + | sort -rh | head -n 10

In this article, you will learn how to find the largest files and directories consuming disk space in Linux using the du, find, and ncdu commands with examples.
Run the following command to find out the top 5 biggest directories under /home partition.

Similar Posts