Google Plus

How to find large files and directories in Linux

Written by Mel Kham on . Posted in Frequently Asked Questions

Question:

 

 

How to  find the largest top 20 files and directories in my Linux ?

 

Answer :

To  find   big  files  and  directories   you have  to use  3  commands is  1  line   du  sort  and  head 

 

  • du : Estimate file space usage
  • sort : Sort lines of text files or given input data
  • head : Output the first part of files i.e. to display first 10 largest file

 

 

Let  give  on example  . 

find  largets 20 files  or  directories  . i  prefere root  acces  to execute  the  commands

 

#du -a /var | sort -n -r | head -n 20

 

output

 

 

[root@localhost ~]# du -a /etc  | sort -n -r | head -20
125520  /etc
66376   /etc/gconf
44932   /etc/gconf/gconf.xml.defaults
43084   /etc/selinux
43052   /etc/selinux/targeted
40772   /etc/selinux/targeted/modules
40740   /etc/selinux/targeted/modules/active
21388   /etc/gconf/schemas
18928   /etc/selinux/targeted/modules/active/base.linked
14716   /etc/selinux/targeted/modules/active/base.pp
4796    /etc/selinux/targeted/modules/active/modules
2972    /etc/gconf/gconf.xml.defaults/%gconf-tree.xml
2768    /etc/rc.d
1884    /etc/selinux/targeted/policy
1876    /etc/selinux/targeted/policy/policy.21
1876    /etc/selinux/targeted/modules/active/policy.kern
1836    /etc/gconf/schemas/gnome-terminal.schemas
1328    /etc/gconf/schemas/apps_nautilus_preferences.schemas
1284    /etc/firmware
1276    /etc/firmware/microcode.dat
[root@localhost ~]#

 

Explain the  options :

 

  • -a : Include all files, not just directories (du command)
  • -h : Human readable format
  • -n : Numeric sort (sort command)
  • -r : Reverse the result of comparisons (sort command)
  • -n 20 : Display 20 largest file

 

 

 

There  is some Other  scirpts  via  Ineternet   that   doing  The  same  Jobs  Like  :

 

find / -type d -size +1G  (to   fine Directories more  then 1  GB)
For questions please refer to our Q/A forum at : http://ask.unixmen.com

Mel Kham

Founder of Unixmen, Living in Amsterdam. Am working in my free time to help people to understand the Opensource and to explain them in easy way how to make the fist steps to the the light. Working day and night with my Co-founder Zinovsky to keep this website live even with less resources.

Like us on Facebook

This week Top Posts

Write for us

Recent Comments

Pat L

|

I tried it and it works with a regular zip file, but if you password-protect the .zip file it does NOT work.

SK

|

Yes we can. What kind of help you need? We are doing outsourcing and technical support for Linux and Open source worldwide. To know more about the details visit here.

ClintB

|

After install as above, run shell script /opt/Citrix/ICAClient/wfica.sh manually and note lib errors still occur. I had the x64 motif loaded but had to manually install the x86 too. Got that from http://rpmfind.net/linux/rpm2html/search.php?query=libXm.so.4 Even after that, I still had to do a “yum install alsa-lib.i686 alsa-lib.x86_64″ to resolve any additional libasound.so.2 errors. Once those two lib issues were resolved, Citix Web Interface launched apps fine by telling browser to open launch.ica using /opt/Citrix/ICAClient/wfica.sh. Good luck Ernesto!

AD

|

I need some Help on Linux,can you guide me ?

Edson Carlos

|

In debian no found. I need link download install in linux debian

 
IDG Tech Network
Copyright © 2008-2013 Unixmen.com .
Maintained by Anblik .