命令-df/du
原创
©著作权归作者所有:来自51CTO博客作者zhucke的原创作品,请联系作者获取转载授权,否则将追究法律责任
df/du 命令
【NAME】
df - report file system disk space usage
查看文件系统的磁盘空间使用情况
【SYNOPSIS】
df [OPTION]... [FILE]...
【OPTIONS】
-l:仅显示本地文件的相关信息;
-h:human-readable,人类可读的方式显示;
-i:显示inode的使用状态而非blocks;
【EXAMPLES】
示例:df不带参数,查看所有磁盘使用情况,包括网络磁盘。
[root@Centos6.8-180 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/myvg-lv_root
10190136 1576032 8089816 17% /
tmpfs 502068 0 502068 0% /dev/shm
/dev/sda1 487652 34543 427509 8% /boot
/dev/mapper/myvg-lv_home
5029504 136648 4630712 3% /home
/dev/mapper/myvg-lv_usr
15350768 4183516 10380820 29% /usr
/dev/mapper/myvg-lv_var
10190136 4192372 5473476 44% /var
/dev/sr0 3824484 3824484 0 100% /mnt
/dev/sda3 10318244 23036 9771072 1% /mydata
示例:df -l参数,仅显示本地磁盘使用情况
[root@Centos6.8-180 ~]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/myvg-lv_root
10190136 1576032 8089816 17% /
tmpfs 502068 0 502068 0% /dev/shm
/dev/sda1 487652 34543 427509 8% /boot
/dev/mapper/myvg-lv_home
5029504 136648 4630712 3% /home
/dev/mapper/myvg-lv_usr
15350768 4183516 10380820 29% /usr
/dev/mapper/myvg-lv_var
10190136 4192372 5473476 44% /var
/dev/sr0 3824484 3824484 0 100% /mnt
/dev/sda3 10318244 23036 9771072 1% /mydata
示例:df -h参数,以人类可读的方式显示;
[root@Centos6.8-180 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/myvg-lv_root
9.8G 1.6G 7.8G 17% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 477M 34M 418M 8% /boot
/dev/mapper/myvg-lv_home
4.8G 134M 4.5G 3% /home
/dev/mapper/myvg-lv_usr
15G 4.0G 9.9G 29% /usr
/dev/mapper/myvg-lv_var
9.8G 4.0G 5.3G 44% /var
/dev/sr0 3.7G 3.7G 0 100% /mnt
/dev/sda3 9.9G 23M 9.4G 1% /mydata
示例:df -i参数,查看磁盘inode使用情况;
[root@Centos6.8-180 ~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/myvg-lv_root
655360 7659 647701 2% /
tmpfs 125517 1 125516 1% /dev/shm
/dev/sda1 128016 38 127978 1% /boot
/dev/mapper/myvg-lv_home
327680 5518 322162 2% /home
/dev/mapper/myvg-lv_usr
983040 139128 843912 15% /usr
/dev/mapper/myvg-lv_var
655360 6860 648500 2% /var
/dev/sr0 0 0 0 - /mnt
/dev/sda3 655360 12 655348 1% /mydata
du 命令
【NAME】
du - estimate file space usage
估计文件使用空间
【SYNOPSIS】
du [OPTION]... [FILE]...
【OPTIONS】
-a:显示所有文件和目录的大小,包含隐藏文件;
-s: sumary,显示目录
-h: human-readable,以人类可读方式显示;
【EXAMPLES】
示例:du,不带参数
[root@Centos6.8-180 ~]# du /tmp
4 /tmp/.esd-0
4 /tmp/.ICE-unix
4 /tmp/pulse-EDIkCo7tuxQf
4 /tmp/keyring-4uIHsm
44 /tmp
示例:du -a参数,显示所有文件和目录的大小,包含隐藏文件;
[root@Centos6.8-180 ~]# du -a /tmp
4 /tmp/yum_save_tx-2016-12-06-06-27Pkv4_8.yumtx
4 /tmp/yum_save_tx-2016-11-30-18-45HZBw1c.yumtx
4 /tmp/yum_save_tx-2016-11-30-18-38hNP_kI.yumtx
0 /tmp/.esd-0/socket
4 /tmp/.esd-0
4 /tmp/.ICE-unix
4 /tmp/yum_save_tx-2016-11-30-18-378FVx6W.yumtx
4 /tmp/yum_save_tx-2016-12-05-04-50CQAWLw.yumtx
0 /tmp/pulse-EDIkCo7tuxQf/native
4 /tmp/pulse-EDIkCo7tuxQf
4 /tmp/yum_save_tx-2016-12-06-06-37qnGiMz.yumtx
0 /tmp/keyring-4uIHsm/socket.pkcs11
0 /tmp/keyring-4uIHsm/socket.ssh
0 /tmp/keyring-4uIHsm/socket
4 /tmp/keyring-4uIHsm
44 /tmp
示例:du -s /etc,显示/etc/目录下所有文件的大小;
[root@Centos6.8-180 ~]# ls -ld /etc
drwxr-xr-x. 128 root root 12288 12月 6 14:00 /etc
[root@Centos6.8-180 ~]# ls -lhd /etc
drwxr-xr-x. 128 root root 12K 12月 6 14:00 /etc
[root@Centos6.8-180 ~]# ls -lhd /usr
drwxr-xr-x. 14 root root 4.0K 11月 8 18:13 /usr
[root@Centos6.8-180 ~]# du -sh /etc
36M /etc #这是/etc目录内所有文件大小之和;