How To Find Large Files and Folder in Unix

49

Finding the largest files is extremely useful especially when you you’re low on disk space and want to free it up. You want to know which directories and files are eating up more space.

Find Out Top Directories and Files (Disk Space) in Linux

1. How to Find Biggest Folder and Files in Linux

To find out the top largest ten folder and files in the current working directory(/home), just run:

 du -ah /home | sort -n -r | head -n 10

Above example shows, how to find the largest top 10 File/Folder. Please node that above includes files and sub-directories asell.

2. How to Find Biggest Folder in Linux

To find out the top largest ten directories in the current working directory(/home), just run:

 du -Sh /home | sort -n -r | head -n 10

Above example shows, how to find the largest top 10 Folders.

3. How to find the largest top 10 File

To find the largest files (top 10) in a particular location or directory for example “/home”

 find /home -type f -exec du -Sh {} + | sort -rh | head -n 10

Above Find biggest files in any folder recursively.

This can be modified to find Finding the largest files with a specific extension in Linux. Also changing type will give result for folder using find command -type {d:f}.

find / -type f -iname "*.zip" -exec du -sh {} + | sort -rh | head -10

4. Find the biggest files inside current folder

To display the largest files(top 10) in a particular location or directory for example .

ls -lS | head -n 10

This will give you the biggest files in the current folder.

5. Find files larger than a certain size

It’s very simply to find files which are larger than a specified size. The find command accepts a size parameter, and you can specify the limits for file sizes in your command line.

find . -size +1G

This command will print all the files which are greater than 1GB from current directory and any sub-directory.

6. Find Folder size of one Level recursively

If you want a breakdown of how folder size are in each directory under your current directory:

for i in $(find . -maxdepth 1 -type d) ; do 
 echo -n $i": " ; 
 (du -sh $i) ; 
done

how to check disk space usage in linux - How To Find Large Files and Folder in Unix

LEAVE A REPLY

Please enter your comment!
Please enter your name here