df command
View the total capacity, used capacity, remaining capacity, etc. of the attached disk, without any parameters, which is displayed by K by default.
[root@centos-01 ~]# df
//file system 1K-block Already used Available used% Mount point
/dev/sda3 29140072 1040404 28099668 4% /
devtmpfs 490008 0 490008 0% /dev
tmpfs 499848 0 499848 0% /dev/shm
tmpfs 499848 6808 493040 2% /run
tmpfs 499848 0 499848 0% /sys/fs/cgroup
/dev/sda1 201380 99148 102232 50% /boot
tmpfs 99972 0 99972 0% /run/user/0
- "- h": display in appropriate units.
[root@centos-01 ~]# df -h
//File system capacity used available used% Mount point
/dev/sda3 28G 1016M 27G 4% /
devtmpfs 479M 0 479M 0% /dev
tmpfs 489M 0 489M 0% /dev/shm
tmpfs 489M 6.7M 482M 2% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 197M 97M 100M 50% /boot
tmpfs 98M 0 98M 0% /run/user/0
The "/" and "/ boot" directories are shown here. Use the free command to view the swap
[root@centos-01 ~]# free
total used free shared buff/cache available
Mem: 999696 120460 731228 6808 148008 713160
Swap: 2097148 0 2097148
- "- i": View inodes usage
[root@centos-01 ~]# df -i
//file system Inode Already used(I) available(I) Already used(I)% Mount point
/dev/sda3 14577152 26523 14550629 1% /
devtmpfs 122502 372 122130 1% /dev
tmpfs 124962 1 124961 1% /dev/shm
tmpfs 124962 446 124516 1% /run
tmpfs 124962 16 124946 1% /sys/fs/cgroup
/dev/sda1 102400 327 102073 1% /boot
tmpfs 124962 1 124961 1% /run/user/0
- "- K" and "- M": displayed in K and M units respectively
[root@centos-01 ~]# df -m
//file system 1M-Block used available used% Mount point
/dev/sda3 28458 1016 27442 4% /
devtmpfs 479 0 479 0% /dev
tmpfs 489 0 489 0% /dev/shm
tmpfs 489 7 482 2% /run
tmpfs 489 0 489 0% /sys/fs/cgroup
/dev/sda1 197 97 100 50% /boot
tmpfs 98 0 98 0% /run/user/0
-
Meaning of each column:
The first column is the name of the partition, the second column is the total capacity of the partition, the third column is how much has been used, the fourth column is how much is left, the fifth column is the percentage used, and the sixth column (the last column) is the mount point.
”/dev/shm "is the memory mount point. If you want to put files in memory, you can put them in the directory / dev/shm /.
du command
- "- h": system automatic adjustment unit
- "- s": list only totals
[root@centos-01 ~]# du -sh /root/
40K /root/
[root@centos-01 ~]# du -sh /boot/
87M /boot/
[root@centos-01 ~]# du -sh /etc/passwd
4.0K /etc/passwd
[root@centos-01 ~]# ls -lh /etc/passwd
-rw-r--r--. 1 root root 846 12month 27 05:28 /etc/passwd
ls shows the size of the file itself, du shows the amount of disk space occupied. The disk is divided into blocks. Each block is 4KB. Even if the file size is less than the size of one block, the file will occupy one block.
[root@centos-01 ~]# du /etc/passwd
4 /etc/passwd
[root@centos-01 ~]# du /root/
8 /root/.ssh
40 /root/
If du does not specify a unit, the default display unit is K.