How to find large files in Linux

Chris Worner

Well-known member
Joined
Apr 15, 2016
Messages
254
Best answers
0
Ratings
17
Points
18
#1
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
Joined
Sep 29, 2016
Messages
66
Best answers
0
Ratings
23
Points
0
#2
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

Moderator
Staff Member
Joined
Jul 5, 2016
Messages
1,031
Best answers
0
Ratings
202
Points
63
#3
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
664
Best answers
0
Ratings
259 1
Points
63
#4
Here's mine

du -a /var | sort -n -r | head -n 10
This command will display top 10 biggest files on whole your Linux.
 
Joined
Jan 18, 2016
Messages
40
Best answers
0
Ratings
7
Points
0
#5
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
Joined
Mar 17, 2017
Messages
76
Best answers
0
Ratings
3
Points
8
#7
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
Joined
Apr 11, 2017
Messages
65
Best answers
0
Ratings
5 2
Points
8
#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
Joined
Mar 11, 2014
Messages
97
Best answers
0
Ratings
9
Points
8
#9
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
Joined
Jan 18, 2017
Messages
279
Best answers
1
Ratings
63 3
Points
28
#10
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
 
Joined
Mar 15, 2017
Messages
33
Best answers
0
Points
0
#11
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
Joined
May 18, 2017
Messages
89
Best answers
0
Ratings
12
Points
0
#12
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
Joined
Jul 25, 2017
Messages
650
Best answers
1
Ratings
64 6
Points
28
#13
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
 
Joined
May 29, 2017
Messages
49
Best answers
0
Points
0
#14
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 Threads
Replies
0
Views
2
Replies
2
Views
23
Replies
3
Views
41
Recommended Threads
Replies
2
Views
1,348
Replies
1
Views
1,292
Replies
4
Views
2,118

Latest Hosting OffersNew Reviews

Sponsors

Latest Blog ArticlesMost Viewed Threads