Find The Largest Top 10 Files and Directories on Linux
2013-07-20 03:58
716 查看
Sometime it is necessary to find out what file(s) or directories are eating up all your disk space. Further, it may be necessary to find out it at the particular location such as /tmp or /var or /home.
There is no simple command available to find out the largest files/directories on a Linux/UNIX/BSD filesystem. However, combination of following three commands (using pipes) you can easily find out list of largest files:
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.
Type the following command at the shell prompt to find out top 10 largest file/directories:
If you want more human readable output try:
du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
du command -s option : show only a total for each argument (summary).
du command -x option : skip directories on different file systems.
sort command -r option : reverse the result of comparisons.
sort command -h option : compare human readable numbers. This is GNU sort specific option only.
head command -10 OR -n 10 option : show the first 10 lines.
The above command will only work of GNU/sort is installed. Other Unix like operating system should use the following version (see comments below):
There is no simple command available to find out the largest files/directories on a Linux/UNIX/BSD filesystem. However, combination of following three commands (using pipes) you can easily find out list of largest files:
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.
Type the following command at the shell prompt to find out top 10 largest file/directories:
# du -a /var | sort -n -r | head -n 10Output:
1008372 /var 313236 /var/www 253964 /var/log 192544 /var/lib 152628 /var/spool 152508 /var/spool/squid 136524 /var/spool/squid/00 95736 /var/log/mrtg.log 74688 /var/log/squid 62544 /var/cache
If you want more human readable output try:
$ cd /path/to/some/where $ du -hsx * | sort -rh | head -10Where,
du command -h option : display sizes in human readable format (e.g., 1K, 234M, 2G).
du command -s option : show only a total for each argument (summary).
du command -x option : skip directories on different file systems.
sort command -r option : reverse the result of comparisons.
sort command -h option : compare human readable numbers. This is GNU sort specific option only.
head command -10 OR -n 10 option : show the first 10 lines.
The above command will only work of GNU/sort is installed. Other Unix like operating system should use the following version (see comments below):
for i in G M K; do du -ah | grep [0-9]$i | sort -nr -k 1; done | head -n 11
相关文章推荐
- How to diff and merge files or directories on Linux
- Find the 10 Top Sites on the Web About: 这个网站不错,吸流量
- Find the Top 10 commands in your linux box!
- Find Out Top Ten Largest Files in Linux
- Linux_10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Dir
- 10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories
- Bash/KSH/SH Shell: Find The Length Of a String On a UNIX, Linux, BSD, and OS X
- 每日一命令(10)cat (concatenate files and print on the standard output)
- Linux - 操作文件与目录(manipulating files and directories)
- linux 学习笔记之 Files and Directories
- How are the icon files in my application bundle used on iPad and iPhone?
- You should be the top dog in your department and always keep an eye on the outside world.
- how to find the tomcat version info on linux
- Understanding the Load Average on Linux and Other Unix-like Systems
- Linux - 操作文件与目录(manipulating files and directories)
- How can I remove all "name" files in all of my subdirectories on Linux
- Linux Log files and usage on Ubuntu
- How to find PID of process listening on a port in Linux? netstat and lsof command examples
- linux终端错误:Unable to find the ncurses libraries or the required header files
- linux之Unable to find the ncurses libraries or the required header files.错误解决办法