1. df
语法:
df [选项]... [FILE]...
显示每个指定文件所在的文件系统的信息,默认是显示所有文件系统
参数:
- -a, --all 包含虚拟、重复和无法访问的文件系统
- -h, --human-readable 以 1024 为基底显示大小(例如:1023M)
- -t, --type=类型 只显示指定文件系统为指定类型的信息
- -T, --print-type 显示文件系统类型
- --total 省略所有对可用空间无显著影响的项并生成总计值
zxm@zxm-pc:~$ df -h
文件系统 容量 已用 可用 已用% 挂载点
udev 16G 0 16G 0% /dev
tmpfs 3.2G 2.0M 3.2G 1% /run
/dev/nvme0n1p2 457G 129G 306G 30% /
tmpfs 16G 398M 16G 3% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
tmpfs 16G 0 16G 0% /run/qemu
/dev/loop0 128K 128K 0 100% /snap/bare/5
/dev/loop2 54M 54M 0 100% /snap/snapd/18933
/dev/loop1 64M 64M 0 100% /snap/core20/1852
/dev/loop3 46M 46M 0 100% /snap/snap-store/638
/dev/loop4 350M 350M 0 100% /snap/gnome-3-38-2004/140
/dev/loop5 64M 64M 0 100% /snap/core20/1828
/dev/loop6 350M 350M 0 100% /snap/gnome-3-38-2004/137
/dev/loop7 50M 50M 0 100% /snap/snapd/18596
/dev/loop9 46M 46M 0 100% /snap/snap-store/599
/dev/loop8 92M 92M 0 100% /snap/gtk-common-themes/1535
/dev/nvme0n1p1 511M 5.3M 506M 2% /boot/efi
tmpfs 3.2G 40K 3.2G 1% /run/user/1000
/dev/sda1 10G 16K 10G 1% /mnt/data1
/dev/sda2 10G 8.0K 10G 1% /mnt/data2
zxm@zxm-pc:~$ df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
udev devtmpfs 16G 0 16G 0% /dev
tmpfs tmpfs 3.2G 2.0M 3.2G 1% /run
/dev/nvme0n1p2 ext4 457G 129G 306G 30% /
tmpfs tmpfs 16G 398M 16G 3% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
tmpfs tmpfs 16G 0 16G 0% /run/qemu
/dev/loop0 squashfs 128K 128K 0 100% /snap/bare/5
/dev/loop2 squashfs 54M 54M 0 100% /snap/snapd/18933
/dev/loop1 squashfs 64M 64M 0 100% /snap/core20/1852
/dev/loop3 squashfs 46M 46M 0 100% /snap/snap-store/638
/dev/loop4 squashfs 350M 350M 0 100% /snap/gnome-3-38-2004/140
/dev/loop5 squashfs 64M 64M 0 100% /snap/core20/1828
/dev/loop6 squashfs 350M 350M 0 100% /snap/gnome-3-38-2004/137
/dev/loop7 squashfs 50M 50M 0 100% /snap/snapd/18596
/dev/loop9 squashfs 46M 46M 0 100% /snap/snap-store/599
/dev/loop8 squashfs 92M 92M 0 100% /snap/gtk-common-themes/1535
/dev/nvme0n1p1 vfat 511M 5.3M 506M 2% /boot/efi
tmpfs tmpfs 3.2G 40K 3.2G 1% /run/user/1000
/dev/sda1 vfat 10G 16K 10G 1% /mnt/data1
/dev/sda2 vfat 10G 8.0K 10G 1% /mnt/data2
zxm@zxm-pc:~$ df -aTh
文件系统 类型 容量 已用 可用 已用% 挂载点
sysfs sysfs 0 0 0 - /sys
proc proc 0 0 0 - /proc
udev devtmpfs 16G 0 16G 0% /dev
devpts devpts 0 0 0 - /dev/pts
tmpfs tmpfs 3.2G 2.0M 3.2G 1% /run
/dev/nvme0n1p2 ext4 457G 129G 306G 30% /
securityfs securityfs 0 0 0 - /sys/kernel/security
tmpfs tmpfs 16G 401M 16G 3% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
cgroup2 cgroup2 0 0 0 - /sys/fs/cgroup/unified
cgroup cgroup 0 0 0 - /sys/fs/cgroup/systemd
pstore pstore 0 0 0 - /sys/fs/pstore
efivarfs efivarfs 0 0 0 - /sys/firmware/efi/efivars
bpf bpf 0 0 0 - /sys/fs/bpf
cgroup cgroup 0 0 0 - /sys/fs/cgroup/devices
cgroup cgroup 0 0 0 - /sys/fs/cgroup/hugetlb
cgroup cgroup 0 0 0 - /sys/fs/cgroup/pids
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/cpu,cpuacct
cgroup cgroup 0 0 0 - /sys/fs/cgroup/cpuset
cgroup cgroup 0 0 0 - /sys/fs/cgroup/perf_event
cgroup cgroup 0 0 0 - /sys/fs/cgroup/net_cls,net_prio
cgroup cgroup 0 0 0 - /sys/fs/cgroup/rdma
cgroup cgroup 0 0 0 - /sys/fs/cgroup/misc
cgroup cgroup 0 0 0 - /sys/fs/cgroup/memory
systemd-1 - - - - - /proc/sys/fs/binfmt_misc
mqueue mqueue 0 0 0 - /dev/mqueue
debugfs debugfs 0 0 0 - /sys/kernel/debug
hugetlbfs hugetlbfs 0 0 0 - /dev/hugepages
tracefs tracefs 0 0 0 - /sys/kernel/tracing
fusectl fusectl 0 0 0 - /sys/fs/fuse/connections
configfs configfs 0 0 0 - /sys/kernel/config
tmpfs tmpfs 16G 0 16G 0% /run/qemu
/dev/loop0 squashfs 128K 128K 0 100% /snap/bare/5
/dev/loop2 squashfs 54M 54M 0 100% /snap/snapd/18933
/dev/loop1 squashfs 64M 64M 0 100% /snap/core20/1852
/dev/loop3 squashfs 46M 46M 0 100% /snap/snap-store/638
/dev/loop4 squashfs 350M 350M 0 100% /snap/gnome-3-38-2004/140
/dev/loop5 squashfs 64M 64M 0 100% /snap/core20/1828
/dev/loop6 squashfs 350M 350M 0 100% /snap/gnome-3-38-2004/137
/dev/loop7 squashfs 50M 50M 0 100% /snap/snapd/18596
/dev/loop9 squashfs 46M 46M 0 100% /snap/snap-store/599
/dev/loop8 squashfs 92M 92M 0 100% /snap/gtk-common-themes/1535
binfmt_misc binfmt_misc 0 0 0 - /proc/sys/fs/binfmt_misc
/dev/nvme0n1p1 vfat 511M 5.3M 506M 2% /boot/efi
tmpfs tmpfs 3.2G 40K 3.2G 1% /run/user/1000
gvfsd-fuse fuse.gvfsd-fuse 0 0 0 - /run/user/1000/gvfs
/dev/fuse fuse 0 0 0 - /run/user/1000/doc
/dev/sda1 vfat 10G 16K 10G 1% /mnt/data1
/dev/sda2 vfat 10G 8.0K 10G 1% /mnt/data2
overlay - - - - - /var/lib/docker/overlay2/9cf60e0fb06a4a0bddb78c942f16b94c1b972bb088b42691a14f009581117c26/merged
nsfs - - - - - /run/docker/netns/a6288e96b36f
zxm@zxm-pc:~$ df --total -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
udev devtmpfs 16G 0 16G 0% /dev
tmpfs tmpfs 3.2G 2.0M 3.2G 1% /run
/dev/nvme0n1p2 ext4 457G 129G 306G 30% /
tmpfs tmpfs 16G 404M 16G 3% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 16G 0 16G 0% /sys/fs/cgroup
tmpfs tmpfs 16G 0 16G 0% /run/qemu
/dev/loop0 squashfs 128K 128K 0 100% /snap/bare/5
/dev/loop2 squashfs 54M 54M 0 100% /snap/snapd/18933
/dev/loop1 squashfs 64M 64M 0 100% /snap/core20/1852
/dev/loop3 squashfs 46M 46M 0 100% /snap/snap-store/638
/dev/loop4 squashfs 350M 350M 0 100% /snap/gnome-3-38-2004/140
/dev/loop5 squashfs 64M 64M 0 100% /snap/core20/1828
/dev/loop6 squashfs 350M 350M 0 100% /snap/gnome-3-38-2004/137
/dev/loop7 squashfs 50M 50M 0 100% /snap/snapd/18596
/dev/loop9 squashfs 46M 46M 0 100% /snap/snap-store/599
/dev/loop8 squashfs 92M 92M 0 100% /snap/gtk-common-themes/1535
/dev/nvme0n1p1 vfat 511M 5.3M 506M 2% /boot/efi
tmpfs tmpfs 3.2G 40K 3.2G 1% /run/user/1000
/dev/sda1 vfat 10G 16K 10G 1% /mnt/data1
/dev/sda2 vfat 10G 8.0K 10G 1% /mnt/data2
total - 548G 131G 394G 25% -
zxm@zxm-pc:~$ df -Th t.log
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/nvme0n1p2 ext4 457G 129G 306G 30% /
2. du
语法:
du [选项]... [文件]...
计算每个文件的磁盘用量,目录则取总用量
参数:
- -a, --all 输出所有文件的磁盘用量,不仅仅是目录
- -h, --human-readable 以人类可读的格式输出大小(例如,1K 234M 2G)
- -s, --summarize 只分别计算命令列中每个参数所占的总用量
- -d, --max-depth=N 仅当目录(或在 --all 选项启用时包括文件)层级不高于命令行参数指定的 N 层时输出对应目录或文件的对应大小;--max-depth=0 等效于 --summarize
zxm@zxm-pc:~/a1$ du -h
4.0K ./b3
40K ./b1/c2
40K ./b1/c1
120K ./b1
40K ./b2
204K .
zxm@zxm-pc:~/a1$ du -ah
36K ./a1.log
4.0K ./b3
36K ./b1/c2/c2.log
40K ./b1/c2
36K ./b1/b1.log
36K ./b1/c1/c1.log
40K ./b1/c1
120K ./b1
36K ./b2/b2.log
40K ./b2
204K .
zxm@zxm-pc:~/a1$ du -h b1/
40K b1/c2
40K b1/c1
120K b1/
zxm@zxm-pc:~/a1$ du -ah b1/
36K b1/c2/c2.log
40K b1/c2
36K b1/b1.log
36K b1/c1/c1.log
40K b1/c1
120K b1/
zxm@zxm-pc:~/a1$ du -sh b1/
120K b1/
zxm@zxm-pc:~/a1$ du -h --max-depth=1
4.0K ./b3
120K ./b1
40K ./b2
204K .
zxm@zxm-pc:~/a1$ du -ah --max-depth=1
36K ./a1.log
4.0K ./b3
120K ./b1
40K ./b2
204K .
zxm@zxm-pc:~/a1$ du -ah -d1
36K ./a1.log
4.0K ./b3
120K ./b1
40K ./b2
204K .
3.lsblk
显示系统中所有磁盘设备的使用情况信息:
zxm@zxm-pc:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 298.1G 0 disk
├─sda1 8:1 0 10G 0 part
└─sda2 8:2 0 10G 0 part
nvme0n1 259:0 0 465.8G 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
└─nvme0n1p2 259:2 0 465.3G 0 part /
显示系统中磁盘设备的归属及权限信息:
zxm@zxm-pc:~$ lsblk -m
NAME SIZE OWNER GROUP MODE
sda 298.1G root disk brw-rw----
├─sda1 10G root disk brw-rw----
└─sda2 10G root disk brw-rw----
nvme0n1 465.8G root disk brw-rw----
├─nvme0n1p1 512M root disk brw-rw----
└─nvme0n1p2 465.3G root disk brw-rw----
显示文件系统信息:
zxm@zxm-pc:~$ lsblk -f
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT
sda
├─sda1 vfat E2B8-AD39
└─sda2 vfat E7FA-082E
nvme0n1
├─nvme0n1p1 vfat A671-82C1 504.9M 1% /boot/efi
└─nvme0n1p2 ext4 df86aa68-faf7-44f2-8b9d-defd7b4e6697 293.6G 31% /