一、du命令
- [root@wc1 mysql]# du --help
- Usage: du [OPTION]... [FILE]...
- or: du [OPTION]... --files0-from=F
- Summarize disk usage of each FILE, recursively for directories.
- Mandatory arguments to long options are mandatory for short options too.
- -a, --all write counts for all files, not just directories
- .......
这个命令可以显示每个文件的磁盘使用的概况,对于目录还可以进行递归显示里面的所有文件的情况。
举例:
显示当前目录的总大小:
- [root@ggg2 mysqldata]# du -s -h
- 7.2G .
显示当前目录中的所有子目录、文件的大小,这里只取前10条:
- [root@ggg2 mysqldata]# du -ah | head -10
- 4.0K ./scripts/mysql_db_shutdown.sh
- 4.0K ./scripts/mysql_full_backup_by_xtra.sh~
- 4.0K ./scripts/mysqlplus.sh
- 4.0K ./scripts/mysql_env.ini
- 4.0K ./scripts/mysql_full_backup_by_xtra.sh
- 4.0K ./scripts/mysql_db_startup.sh
- 28K ./scripts
- 129M ./3306_cp/data/ib_logfile1
- 12K ./3306_cp/data/performance_schema/events_stages_current.frm
- 12K ./3306_cp/data/performance_schema/events_stages_history_long.frm
显示子目录backup的所有子目录的明细汇总信息,还有一个额外的 total 值,类似sql 语句里的rollup效果:
- [root@ggg2 mysqldata]# du -ch backup | grep total
- 2.4G total
同上,只是这里的-0表示不换行显示:
-0, --null end each output line with 0 byte rather than newline
- [root@ggg2 mysqldata]# du -c -0h backup
- 636K backup/2016-10-16_21-47-35/performance_schema20K backup/2016-10-16_21-47-35/ggg748K backup/2016-10-16_21-47-35/test1.6M backup/2016-10-16_21-47-35/mysql2.4G backup/2016-10-16_21-47-352.3M backup/mysql_full2.4G b
二、df命令
- [root@wc1 mysql]# df --help
- Usage: df [OPTION]... [FILE]...
- Show information about the file system on which each FILE resides,
- or all file systems by default.
- Mandatory arguments to long options are mandatory for short options too.
- -a, --all include dummy file systems
- ......
这个命令是显示每个文件所驻留的文件系统的信息,默认是所有文件系统的情况。
举例:
显示每个分区的信息:
- [root@ggg2 mysqldata]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/sda3 16G 13G 2.4G 85% /
- tmpfs 936M 228K 936M 1% /dev/shm
- /dev/sda1 194M 36M 148M 20% /boot
显示分区信息,包括虚拟文件系统:
- [root@ggg2 mysqldata]# df -a -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/sda3 16G 13G 2.4G 85% /
- proc 0 0 0 - /proc
- sysfs 0 0 0 - /sys
- devpts 0 0 0 - /dev/pts
- tmpfs 936M 228K 936M 1% /dev/shm
- /dev/sda1 194M 36M 148M 20% /boot
- none 0 0 0 - /proc/sys/fs/binfmt_misc
- vmware-vmblock 0 0 0 - /var/run/vmblock-fuse
- gvfs-fuse-daemon 0 0 0 - /root/.gvfs
显示inode的 信息,而不是磁盘的使用情况:
- [root@ggg2 mysqldata]# df -i -h
- Filesystem Inodes IUsed IFree IUse% Mounted on
- /dev/sda3 1015K 119K 896K 12% /
- tmpfs 234K 6 234K 1% /dev/shm
- /dev/sda1 50K 39 50K 1% /boot