譬如有时候磁盘空间告警了,而你平时又疏于管理、监控文件的增长,那么我需要快速的了解哪些目录变得比较大,那么此时我们可以借助du命令来帮我们解决这个问题。
[root@getlnx01 u03]# du -h --max-depth=1
16K ./lost+found
33G ./flash_recovery_area
37G ./oradata
70G .
如果你想知道flash_recovery_area目录下面有哪些大文件夹,那么可以将参数max-depth=2 ,如果你想对搜索出来的结果进行排序,那么可以借助于sort命令。如下所示
[root@getlnx01 u03]# du -h --max-depth=2 | sort -n
3.5G ./flash_recovery_area/EPPS
16K ./lost+found
29G ./flash_recovery_area/backup
33G ./flash_recovery_area
37G ./oradata
37G ./oradata/epps
70G .
[root@getlnx01 u03]# du -hm --max-depth=2 | sort -n
1 ./lost+found
3527 ./flash_recovery_area/EPPS
29544 ./flash_recovery_area/backup
33070 ./flash_recovery_area
37705 ./oradata
37705 ./oradata/epps
70775 .
[root@getlnx01 u03]# cd /
[root@getlnx01 /]# du -hm --max-depth=2 | sort -n
有时候搜索出来的结果太多了(譬如,我从根目录开始搜索),一直在刷屏,如果我只想查出最大的12个文件夹,怎么办呢?此时就要借助head命令来显示了
[root@getlnx01 /]# du -hm --max-depth=2 | sort -nr | head -12
407480 .
167880 ./u04
158685 ./u02/oradata
158685 ./u02
152118 ./u04/oradata
70775 ./u03
37705 ./u03/oradata
33070 ./u03/flash_recovery_area
5995 ./u01/app
5995 ./u01
3551 ./usr
1558 ./usr/share
[root@getlnx01 /]#
[root@getlnx01 u03]# du -h --max-depth=1
16K ./lost+found
33G ./flash_recovery_area
37G ./oradata
70G .
如果你想知道flash_recovery_area目录下面有哪些大文件夹,那么可以将参数max-depth=2 ,如果你想对搜索出来的结果进行排序,那么可以借助于sort命令。如下所示
[root@getlnx01 u03]# du -h --max-depth=2 | sort -n
3.5G ./flash_recovery_area/EPPS
16K ./lost+found
29G ./flash_recovery_area/backup
33G ./flash_recovery_area
37G ./oradata
37G ./oradata/epps
70G .
[root@getlnx01 u03]# du -hm --max-depth=2 | sort -n
1 ./lost+found
3527 ./flash_recovery_area/EPPS
29544 ./flash_recovery_area/backup
33070 ./flash_recovery_area
37705 ./oradata
37705 ./oradata/epps
70775 .
[root@getlnx01 u03]# cd /
[root@getlnx01 /]# du -hm --max-depth=2 | sort -n
有时候搜索出来的结果太多了(譬如,我从根目录开始搜索),一直在刷屏,如果我只想查出最大的12个文件夹,怎么办呢?此时就要借助head命令来显示了
[root@getlnx01 /]# du -hm --max-depth=2 | sort -nr | head -12
407480 .
167880 ./u04
158685 ./u02/oradata
158685 ./u02
152118 ./u04/oradata
70775 ./u03
37705 ./u03/oradata
33070 ./u03/flash_recovery_area
5995 ./u01/app
5995 ./u01
3551 ./usr
1558 ./usr/share
[root@getlnx01 /]#