linux du df ls
du可以查看文件和文件夹的大小,df主要查看数据库大小,查看分区的的磁盘使用情况,ls可以添加-h参数,方便我们查看文件大小
df可以查看一级文件夹大小、使用比例、档案系统及其挂入点,但对文件却无能为力。
du可以查看文件及文件夹的大小。
两者配合使用,非常有效。比如用df查看哪个一级目录过大,然后用df查看文件夹或文件的大小,如此便可迅速确定症结
[root@LocalWeb01 eaccelerator]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 6.7G 12G 37% /
tmpfs 506M 0 506M 0% /dev/shm
.host:/ 101G 96G 5.0G 96% /mnt/hgfs
[root@LocalWeb01 eaccelerator]# du -h --max-depth=1 /data/wwwroot/
11M /data/wwwroot/test
[root@LocalWeb01 eaccelerator]# ls -l
total 128
drwxrwxrwx 18 root root 4096 Nov 6 07:42 0
drwxrwxrwx 18 root root 4096 Nov 6 07:42 1
drwxrwxrwx 18 root root 4096 Nov 6 07:42 2
drwxrwxrwx 18 root root 4096 Nov 6 07:42 3
drwxrwxrwx 18 root root 4096 Nov 6 07:42 4
drwxrwxrwx 18 root root 4096 Nov 6 07:42 5
drwxrwxrwx 18 root root 4096 Nov 6 07:42 6
drwxrwxrwx 18 root root 4096 Nov 6 07:42 7
drwxrwxrwx 18 root root 4096 Nov 6 07:42 8
drwxrwxrwx 18 root root 4096 Nov 6 07:42 9
drwxrwxrwx 18 root root 4096 Nov 6 07:42 a
drwxrwxrwx 18 root root 4096 Nov 6 07:42 b
drwxrwxrwx 18 root root 4096 Nov 6 07:42 c
drwxrwxrwx 18 root root 4096 Nov 6 07:42 d
drwxrwxrwx 18 root root 4096 Nov 6 07:42 e
drwxrwxrwx 18 root root 4096 Nov 6 07:42 f
[root@LocalWeb01 eaccelerator]# ls -lh
total 128K
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 0
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 1
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 2
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 3
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 4
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 5
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 6
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 7
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 8
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 9
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 a
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 b
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 c
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 d
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 e
drwxrwxrwx 18 root root 4.0K Nov 6 07:42 f