df -[ahikHTm] 文件或目录名
-a 列出所有文件系统
-k 以KBytes显示容量
-m 以MBytes显示容量
-h 以人较为能接受的方式显示容量GBytes、MBytes、KBytes
-H 以1000K=1M进位
-T 连同partition与filesystem名称(xfs)也一起列出
-i 不用磁盘容量以inode数量显示
默认以1K-blocks显示文件系统大小
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 17811456 1293760 16517696 8% /
devtmpfs 919496 0 919496 0% /dev
tmpfs 931624 0 931624 0% /dev/shm
tmpfs 931624 17948 913676 2% /run
tmpfs 931624 0 931624 0% /sys/fs/cgroup
/dev/sda1 1038336 148572 889764 15% /boot
tmpfs 186328 0 186328 0% /run/user/0
以inode数量显示文件系统大小
# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/centos-root 8910848 35262 8875586 1% /
devtmpfs 229874 406 229468 1% /dev
tmpfs 232906 1 232905 1% /dev/shm
tmpfs 232906 745 232161 1% /run
tmpfs 232906 16 232890 1% /sys/fs/cgroup
/dev/sda1 524288 327 523961 1% /boot
tmpfs 232906 1 232905 1% /run/user/0
以人较为能接受的方式显示容量GBytes、MBytes、KBytes
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 1.3G 16G 8% /
devtmpfs 898M 0 898M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 18M 893M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/sda1 1014M 146M 869M 15% /boot
tmpfs 182M 0 182M 0% /run/user/0
列出所有文件系统连同partition与filesystem名称(xfs)也一起列出
# df -aT
Filesystem Type 1K-blocks Used Available Use% Mounted on
rootfs - - - - - /
sysfs sysfs 0 0 0 - /sys
proc proc 0 0 0 - /proc
devtmpfs devtmpfs 919496 0 919496 0% /dev
securityfs securityfs 0 0 0 - /sys/kernel/security
tmpfs tmpfs 931624 0 931624 0% /dev/shm
devpts devpts 0 0 0 - /dev/pts
tmpfs tmpfs 931624 17948 913676 2% /run
tmpfs tmpfs 931624 0 931624 0% /sys/fs/cgroup
cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore pstore 0 0 0 - /sys/fs/pstore
cgroup cgroup 0 0 0 - /sys/fs/cgroup/pids
cgroup cgroup 0 0 0 - /sys/fs/cgroup/devices
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpu,cpuacct
cgroup cgroup 0 0 0 - /sys/fs/cgroup/perf_event
cgroup cgroup 0 0 0 - /sys/fs/cgroup/blkio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/freezer
cgroup cgroup 0 0 0 - /sys/fs/cgroup/hugetlb
cgroup cgroup 0 0 0 - /sys/fs/cgroup/memory
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpuset
cgroup cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio
configfs configfs 0 0 0 - /sys/kernel/config
/dev/mapper/centos-root xfs 17811456 1293760 16517696 8% /
selinuxfs selinuxfs 0 0 0 - /sys/fs/selinux
mqueue mqueue 0 0 0 - /dev/mqueue
hugetlbfs hugetlbfs 0 0 0 - /dev/hugepages
debugfs debugfs 0 0 0 - /sys/kernel/debug
systemd-1 - - - - - /proc/sys/fs/binfmt_misc
/dev/sda1 xfs 1038336 148572 889764 15% /boot
tmpfs tmpfs 186328 0 186328 0% /run/user/0
binfmt_misc binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
显示当前文件的文件系统空间
# df -h /etc/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 17G 1.3G 16G 8% /
查看磁盘空间以及inode数
# df -ih
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/centos-root 8.5M 35K 8.5M 1% /
devtmpfs 225K 406 225K 1% /dev
tmpfs 228K 1 228K 1% /dev/shm
tmpfs 228K 745 227K 1% /run
tmpfs 228K 16 228K 1% /sys/fs/cgroup
/dev/sda1 512K 327 512K 1% /boot
tmpfs 228K 1 228K 1% /run/user/0
-a 列出所有文件与目录容量,因为默认仅统计目录底下的文件量
-h 以人们较易读的容量格式(G/M)显示
-s 列出总量而已
-S 不包括子目录下的总计
-k 以KBytes显示容量
-m 以MBytes显示容量
列出当前目录下所有文件大小
# du
0 ./.pki/nssdb
0 ./.pki
0 ./test1
36 .
列出当前目录下所有文件大小,文件也一并列出
# du -a
4 ./.bash_logout
4 ./.bash_profile
4 ./.bashrc
4 ./.cshrc
4 ./.tcshrc
4 ./anaconda-ks.cfg
8 ./.bash_history
0 ./.pki/nssdb
0 ./.pki
4 ./.viminfo
0 ./test1
36 .
显示根目录下每个目录的容量
# du -sm /*
0 /bin
113 /boot
0 /dev
31 /etc
1 /home
0 /lib
0 /lib64
0 /media
0 /mnt
0 /opt
du: cannot access ‘/proc/76644/task/76644/fd/4’: No such file or directory
du: cannot access ‘/proc/76644/task/76644/fdinfo/4’: No such file or directory
du: cannot access ‘/proc/76644/fd/4’: No such file or directory
du: cannot access ‘/proc/76644/fdinfo/4’: No such file or directory
0 /proc
1 /root
18 /run
0 /sbin
0 /srv
0 /sys
1 /tmp
1003 /usr
181 /var
软链接文件删除链接将不可用;
硬链接删除原文档,依然可以使用
硬链接只能用于文件不能用于目录,不能跨越文件系统。
根的inode
[root@localhost /]# ll -id / ./ ../
64 dr-xr-xr-x. 17 root root 224 Jun 17 2019 /
64 dr-xr-xr-x. 17 root root 224 Jun 17 2019 ./
64 dr-xr-xr-x. 17 root root 224 Jun 17 2019 ../
tmp创建目录后链接数会增加1,目录的链接数默认为2
[root@localhost tmp]# ll -id
16777288 drwxrwxrwx. 7 root root 141 Mar 22 10:18 .
[root@localhost tmp]# mkdir test1
[root@localhost tmp]# ll -id
16777288 drwxrwxrwx. 8 root root 154 Mar 22 10:19 .
[root@localhost tmp]# ll -id test1/
33664446 drwxr-xr-x. 2 root root 6 Mar 22 10:19 test1/
[root@localhost test1]# ll -id . ./ ../
33664446 drwxr-xr-x. 2 root root 6 Mar 22 10:19 .
33664446 drwxr-xr-x. 2 root root 6 Mar 22 10:19 ./
16777288 drwxrwxrwx. 8 root root 154 Mar 22 10:20 ../
软链接与硬链接使用
# cp -av /etc/passwd .
‘/etc/passwd’ -> ‘./passwd’
当前目录大小,以及当前文件系统inode数量
# du -sb;df -i .
1136 .
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/centos-root 8910848 35259 8875589 1% /
创建硬链接
# ln -v passwd passwd_hl
‘passwd_hl’ => ‘passwd’
目录大小增加17bytes,主要是目录条目占用空间,inode数量不变
# du -sb; df -i .
1153 .
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/centos-root 8910848 35259 8875589 1% /
创建软链接
# ln -sv passwd passwd_sl
‘passwd_sl’ -> ‘passwd’
目录占用空间增加23bytes,inode使用1
# du -sb; df -i .
1176 .
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/mapper/centos-root 8910848 35260 8875588 1% /