aapanelCentosControl PanelCWPHestia CPLinuxUbuntu

How to find Big files in Linux – CWP/Centos/Ubuntu/Debian

In this tutorial we’ll learn how to find big files in Linux, you can use the find command with the du command to search for the files. Here’s how to do it:

Open a terminal/ssh window.

Navigate to the directory where you want to search for big files. For example, to search for big files in your server root / directory, type:

cd /

Type the following command to list all files in the current directory and its subdirectories, sorted by size:

du -ah . | sort -rh | head -n 30

This command uses the du command to calculate the size of each file and the sort command to sort the results in reverse order. The head command is used to show only the first 30 results.

The output will show the size of each file in a human-readable format (such as “1.5M” or “10G”) and the path to the file.

You can modify the command to search for big files in a specific directory or to show more or fewer results. For example, to search for big files in the /home and /var/log directories and show the first 100 results, type:

du -ah /home | sort -rh | head -n 100
du -ah /var/log | sort -rh | head -n 100

Bonus command:

To find big files all over the server disk / :

find / -mount -size +1024k -type f -exec ls -alh {} \;|sort -rnb -k 5|more

example :

[root@server ~]# find / -mount -size +1024k -type f -exec ls -alh {} \;|sort -rnb -k 5|more
-rw-r--r-- 1 clamupdate clamupdate 185M May  6 04:23 /var/lib/clamav/daily.cld
-rw-r--r-- 1 clamupdate clamupdate 163M Sep 22  2021 /var/lib/clamav/main.cvd
-rw------- 1 root mail 137M May  6 16:09 /var/spool/mail/root

Sandeep B.

I'm a system admin and php developer and currently working as System Admin In CWP Control panel, expertise in Linux and Windows administration RHEL certified admin.

Related Articles

Leave a Reply

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

Back to top button