How to find large files in Linux

Chris Worner

Well-known member
Registered
Joined
Apr 15, 2016
Messages
612
Points
28
Are there any commands that allow me find top 10 large files in my VPS Linux?
I tried some ways but not successfully
 

sh-admin

Active member
Registered
Joined
Sep 29, 2016
Messages
66
Points
0
enter the directory where you need to find the large files and use the below command

du -sh *

and it will give you the list of the files with its sizes ... this command takes time to execute as it counts the files size so be patient.
 

LJSHost

Well-known member
Hosting Provider
Registered
Joined
Jul 5, 2016
Messages
1,031
Points
63
As sh-admin said du is very flexible command.
You can also use:

find / -size +50M -exec ls -lh {} \; | awk '{print $5" - "$9}'

This will scan the the file system from / for any files larger than 50MB
 

fwh

Administrator
Staff Member
Joined
Dec 8, 2012
Messages
773
Points
63
Here's mine

du -a /var | sort -n -r | head -n 10
This command will display top 10 biggest files on whole your Linux.
 

UWH-David

Member
Registered
Joined
Jan 18, 2016
Messages
45
Points
8
Although not directly related, you may also find the following useful as well in terms of hunting down usage based on inode/file count. Very useful when hunting down email accounts with ridiculously large file counts.

Code:
find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
 

BlaZeX

Active member
Hosting Provider
Registered
Joined
Mar 17, 2017
Messages
79
Points
8
cd /
for i in *; do echo -e "$(find $i | wc -l)\t$i"; done | sort -n
I use this. Seems to be faster.
 

SolaDrive

Active member
Hosting Provider
Registered
Joined
Apr 11, 2017
Messages
72
Points
8
I'd suggest using this: du -sh * | sort -h

It will show you the biggest files in the directory in order of biggest to smallest.
 

Dopani

Well-known member
Registered
Joined
Mar 11, 2014
Messages
233
Points
18
I'd suggest using this: du -sh * | sort -h

It will show you the biggest files in the directory in order of biggest to smallest.
Nice command @SolaDrive

What parameter can I show from smallest to biggest files?

Code:
cd /
for i in *; do echo -e "$(find $i | wc -l)\t$i"; done | sort -n
I use this. Seems to be faster.
What does it mean in your command?
 

AlbaHost

Well-known member
Moderator
Hosting Provider
Joined
Jan 18, 2017
Messages
775
Points
43
Nice command @SolaDrive

What parameter can I show from smallest to biggest files?



What does it mean in your command?

From biggest to smallest:

for X in $(du -s * | sort -nr | cut -f 2); do du -hs $X ; done
 

optimalgeek

Member
Registered
Joined
Mar 15, 2017
Messages
33
Points
0
You may use the below command.

du -a /var | sort -n -r | head -n 10

Replace 10 for the number of files you want to display.
 

racksandcloud

Well-known member
Registered
Joined
May 18, 2017
Messages
89
Points
0
Hello,


Syntax for RedHat / CentOS / Fedora Linux

find {/path/to/directory/} -type f -size +{size-in-kb}k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Search or find big files Linux (50MB) in current directory, enter:
$ find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

Search in my /var/log directory:
# find /var/log -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
Syntax for Debian / Ubuntu Linux

find {/path/to/directory} -type f -size +{file-size-in-kb}k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

Search in current directory:
$ find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'


You can also use ls command:
$ ls -lS
$ ls -lS | less
$ ls -lS | head +10
 

24x7serverman

Well-known member
Hosting Provider
Registered
Joined
Jul 25, 2017
Messages
651
Points
28
If you will fire the below command then the linux server will display the file with it's size -
du -sch *

If you would like to know the file size of hidden files to then please fire below command -
du -hs .[!.]*

Sort the file size in ascending order -
$ ls -S
$ ls -S -l

OR
find . -type f -print0 | xargs -0 du -h | sort -rh
 

Denis // trabia

Member
Hosting Provider
Registered
Joined
May 29, 2017
Messages
50
Points
6
find / -xdev -type f -size +100M -exec du -sh {} ';' | sort -rh | head -n10

You can adjust the -size option to the file size optimal for you system, for example if you get too less results, you should specify a smaller file size.
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top