在 Linux 和 Unix 中查看磁盘使用情况最常用的应用程序是 杜. 杜,代表 d风险 你sage,被广泛用于找出哪些文件和目录占用了最多的磁盘空间。 还存在许多其他命令行和图形工具来完成此任务。 我们已经介绍了其中一些,并在过去发布在我们的博客中。 今天,我们将另一个磁盘使用检查器命名为 达夫.
Duf 是一个命令行实用程序,用于查找 Linux 和类 Unix 系统中的磁盘使用情况。 它以漂亮的表格列和用户友好的布局显示磁盘使用详细信息。 您甚至可以在 JSON 格式也一样。
如果输出超出屏幕的可见部分,它会自动调整终端的宽度。 您可以按总大小、文件系统类型、已用和可用空间、挂载点和 inode 对结果进行排序。 还可以从输出中显示、隐藏和排除特定设备的详细信息。
Duf 是 d风险 你智者/F里。 它是一个开源应用程序,用 去 编程语言并在 MIT 许可下发布。 它可以在 GNU/Linux、BSD 和 Mac OS 下运行。
在 Linux 上安装 Duf
目前,Duf 已被打包用于基于 Arch、基于 DEB 和基于 RPM 的 Linux 操作系统。
Duf 可在 AUR. 如果您使用的是 Arch Linux 或任何 Arch 变体,您可以使用 AUR 帮助程序安装它,例如 example 耶.
$ yay -S duf
在基于 DEB 的系统(例如 Debian、Ubuntu、Linux Mint)上,从 发布页面 并使用系统的包管理器安装它。
$ sudo apt install gdebi
$ sudo gdebi duf_0.3.1_linux_amd64.deb
在基于 RPM 的系统上,例如 RHEL、CentOS、 Fedora,下载 .rpm 二进制文件并使用命令安装它:
$ sudo rpm -Uvh duf_0.3.1_linux_amd64.rpm
我们也可以从源代码构建它。 确保你有 安装的GO语言 在您的系统上。
Git 克隆 duf 存储库:
$ git clone https://github.com/muesli/duf.git
上面的命令会将duf在线存储库的内容克隆到名为“duf”的本地目录中。 转到该目录:
$ cd duf
使用命令编译并安装它:
$ go build
在 Linux 和 Unix 上使用 Duf 查看磁盘使用情况
使用 duf 查找磁盘空间使用情况很容易!
您所要做的就是运行 duf
命令没有任何选项,如下所示:
$ duf
样本输出:
╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 local device │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼──────┼────────────┤
│ / │ 457.4G │ 412.1G │ 22.1G │ [##################..] 90.1% │ ext4 │ /dev/sda1 │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴──────┴────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices │
├────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev │ 3.8G │ 0B │ 3.8G │ │ devtmpfs │ udev │
│ /dev/shm │ 3.8G │ 235.3M │ 3.6G │ [#...................] 6.0% │ tmpfs │ tmpfs │
│ /run │ 787.0M │ 1.8M │ 785.2M │ [....................] 0.2% │ tmpfs │ tmpfs │
│ /run/lock │ 5.0M │ 4.0K │ 5.0M │ [....................] 0.1% │ tmpfs │ tmpfs │
│ /run/snapd/ns │ 787.0M │ 1.8M │ 785.2M │ [....................] 0.2% │ tmpfs │ tmpfs │
│ /run/user/1000 │ 787.0M │ 238.2M │ 548.8M │ [######..............] 30.3% │ tmpfs │ tmpfs │
│ /sys/fs/cgroup │ 3.8G │ 0B │ 3.8G │ │ tmpfs │ tmpfs │
╰────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────────┴────────────╯
正如您在上面的输出中看到的那样,Duf 以漂亮的表格列格式列出了以下详细信息:
- 已安装设备的总数,
- 挂载点,
- 根分区的总大小,
- 已用和可用磁盘空间的总大小,
- 总磁盘使用百分比,
- 文件系统类型,
- 文件系统名称等
要显示所有详细信息,包括伪、重复和不可访问的文件系统,请运行:
$ duf --all
样本输出:
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 24 local devices │
├────────────────────────────────┬────────┬────────┬───────┬───────────────────────────────┬──────────┬─────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────────────────────┼────────┼────────┼───────┼───────────────────────────────┼──────────┼─────────────┤
│ / │ 457.4G │ 412.1G │ 22.1G │ [##################..] 90.1% │ ext4 │ /dev/sda1 │
│ /run/snapd/ns/multipass.mnt │ 0B │ 0B │ 0B │ │ nsfs │ nsfs │
│ /snap/bashtop/128 │ 23.1M │ 23.1M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop0 │
│ /snap/bashtop/134 │ 23.1M │ 23.1M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop1 │
│ /snap/chromium/1298 │ 162.1M │ 162.1M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop2 │
│ /snap/chromium/1320 │ 162.0M │ 162.0M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop3 │
│ /snap/core/9804 │ 96.6M │ 96.6M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop4 │
│ /snap/core/9993 │ 97.1M │ 97.1M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop6 │
│ /snap/core18/1880 │ 55.0M │ 55.0M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop15 │
│ /snap/core18/1885 │ 55.4M │ 55.4M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop5 │
│ /snap/gifcurry/8 │ 149.0M │ 149.0M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop7 │
│ /snap/gnome-3-26-1604/100 │ 140.8M │ 140.8M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop16 │
│ /snap/gnome-3-26-1604/98 │ 140.8M │ 140.8M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop8 │
│ /snap/gnome-3-28-1804/116 │ 160.2M │ 160.2M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop14 │
│ /snap/gnome-3-28-1804/128 │ 161.5M │ 161.5M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop10 │
│ /snap/gnome-3-34-1804/33 │ 255.6M │ 255.6M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop9 │
│ /snap/gnome-3-34-1804/36 │ 255.6M │ 255.6M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop11 │
│ /snap/gnome-system-monitor/145 │ 2.2M │ 2.2M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop17 │
│ /snap/gnome-system-monitor/148 │ 2.2M │ 2.2M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop18 │
│ /snap/gtk-common-themes/1502 │ 54.9M │ 54.9M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop12 │
│ /snap/gtk-common-themes/1506 │ 62.1M │ 62.1M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop13 │
│ /snap/multipass/2531 │ 220.0M │ 220.0M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop19 │
│ /snap/multipass/2604 │ 220.0M │ 220.0M │ 0B │ [####################] 100.0% │ squashfs │ /dev/loop20 │
│ /sys/fs/fuse/connections │ 0B │ 0B │ 0B │ │ fusectl │ fusectl │
╰────────────────────────────────┴────────┴────────┴───────┴───────────────────────────────┴──────────┴─────────────╯
╭─────────────────────────────────────────────────────────────────────────────────╮
│ 1 FUSE device │
├─────────────────────┬──────┬──────┬───────┬──────┬─────────────────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├─────────────────────┼──────┼──────┼───────┼──────┼─────────────────┼────────────┤
│ /run/user/1000/gvfs │ 0B │ 0B │ 0B │ │ fuse.gvfsd-fuse │ gvfsd-fuse │
╰─────────────────────┴──────┴──────┴───────┴──────┴─────────────────┴────────────╯
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 32 special devices │
├─────────────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬─────────────┬─────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├─────────────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼─────────────┼─────────────┤
│ /dev │ 3.8G │ 0B │ 3.8G │ │ devtmpfs │ udev │
│ /dev/hugepages │ 0B │ 0B │ 0B │ │ hugetlbfs │ hugetlbfs │
│ /dev/mqueue │ 0B │ 0B │ 0B │ │ mqueue │ mqueue │
│ /dev/pts │ 0B │ 0B │ 0B │ │ devpts │ devpts │
│ /dev/shm │ 3.8G │ 224.1M │ 3.6G │ [#...................] 5.7% │ tmpfs │ tmpfs │
│ /proc │ 0B │ 0B │ 0B │ │ proc │ proc │
│ /proc/sys/fs/binfmt_misc │ 0B │ 0B │ 0B │ │ binfmt_misc │ binfmt_misc │
│ /run │ 787.0M │ 1.8M │ 785.2M │ [....................] 0.2% │ tmpfs │ tmpfs │
│ /run/lock │ 5.0M │ 4.0K │ 5.0M │ [....................] 0.1% │ tmpfs │ tmpfs │
│ /run/snapd/ns │ 787.0M │ 1.8M │ 785.2M │ [....................] 0.2% │ tmpfs │ tmpfs │
│ /run/user/1000 │ 787.0M │ 238.2M │ 548.8M │ [######..............] 30.3% │ tmpfs │ tmpfs │
│ /sys │ 0B │ 0B │ 0B │ │ sysfs │ sysfs │
│ /sys/fs/bpf │ 0B │ 0B │ 0B │ │ bpf │ none │
│ /sys/fs/cgroup │ 3.8G │ 0B │ 3.8G │ │ tmpfs │ tmpfs │
│ /sys/fs/cgroup/blkio │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/cpu,cpuacct │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/cpuset │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/devices │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/freezer │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/hugetlb │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/memory │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/net_cls,net_prio │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/perf_event │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/pids │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/rdma │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/systemd │ 0B │ 0B │ 0B │ │ cgroup │ cgroup │
│ /sys/fs/cgroup/unified │ 0B │ 0B │ 0B │ │ cgroup2 │ cgroup2 │
│ /sys/fs/pstore │ 0B │ 0B │ 0B │ │ pstore │ pstore │
│ /sys/kernel/config │ 0B │ 0B │ 0B │ │ configfs │ configfs │
│ /sys/kernel/debug │ 0B │ 0B │ 0B │ │ debugfs │ debugfs │
│ /sys/kernel/security │ 0B │ 0B │ 0B │ │ securityfs │ securityfs │
│ /sys/kernel/tracing │ 0B │ 0B │ 0B │ │ tracefs │ tracefs │
╰─────────────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴─────────────┴─────────────╯
从输出中排除特定设备详细信息
有时,您可能希望从输出中排除一些细节。 例如,以下命令将排除特殊设备的详细信息(例如 /run/lock
, /sys/fs/bpf
)。
$ duf --hide-special
这将仅显示本地设备的磁盘使用详细信息,即从输出中消除特殊设备:
╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 local device │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼──────┼────────────┤
│ / │ 457.4G │ 412.0G │ 22.1G │ [##################..] 90.1% │ ext4 │ /dev/sda1 │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴──────┴────────────╯
其他支持的选项是:
--hide-local
--hide-network
--hide-fuse
--hide-loops
--hide-binds
排序输出
我们可以显示按各种参数排序的磁盘使用详细信息,例如:
mountpoint
,size
,used
,avail
,usage
,inodes
,inodes_used
,inodes_avail
,inodes_usage
,type
,filesystem
等等
例如,要按大小对输出进行排序,请使用以下命令:
$ duf --sort size
按文件系统排序输出:
$ duf --sort filesystem
显示或隐藏特定列
与从输出中排除某些设备详细信息类似,我们还可以在输出中显示或隐藏特定列。
以下命令将显示输出 mountpoint
, size
和 usage
仅列:
$ duf --output mountpoint,size,usage
样本输出:
╭─────────────────────────────────────────────────────╮
│ 1 local device │
├────────────┬────────┬───────────────────────────────┤
│ MOUNTED ON │ SIZE │ USE% │
├────────────┼────────┼───────────────────────────────┤
│ / │ 457.4G │ [##################..] 90.1% │
╰────────────┴────────┴───────────────────────────────╯
╭─────────────────────────────────────────────────────────╮
│ 7 special devices │
├────────────────┬────────┬───────────────────────────────┤
│ MOUNTED ON │ SIZE │ USE% │
├────────────────┼────────┼───────────────────────────────┤
│ /dev │ 3.8G │ │
│ /dev/shm │ 3.8G │ [#...................] 6.9% │
│ /run │ 787.0M │ [....................] 0.2% │
│ /run/lock │ 5.0M │ [....................] 0.1% │
│ /run/snapd/ns │ 787.0M │ [....................] 0.2% │
│ /run/user/1000 │ 787.0M │ [######..............] 30.3% │
│ /sys/fs/cgroup │ 3.8G │ │
╰────────────────┴────────┴───────────────────────────────╯
支持的选项列表是:
mountpoint
,size
,used
,avail
,usage
,inodes
,inodes_used
,inodes_avail
,inodes_usage
,type
,filesystem
.
显示 inode 详细信息
如果要列出 inode 信息而不是块使用情况,请运行以下命令:
$ duf --inodes
以 JSON 格式显示磁盘使用情况输出
我们可以以 JSON 格式显示,而不是以表格列格式显示输出。
为此,请运行:
$ duf --json
样本输出:
[
{
"device": "sysfs",
"device_type": "special",
"mount_point": "/sys",
"fs_type": "sysfs",
"type": "sysfs",
"opts": "rw,nosuid,nodev,noexec,relatime",
"total": 0,
"free": 0,
"used": 0,
"inodes": 0,
"inodes_free": 0,
"inodes_used": 0,
"blocks": 0,
"block_size": 4096
},
.
.
.
{
"device": "binfmt_misc",
"device_type": "special",
"mount_point": "/proc/sys/fs/binfmt_misc",
"fs_type": "binfmt_misc",
"type": "binfmt_misc",
"opts": "rw,nosuid,nodev,noexec,relatime",
"total": 0,
"free": 0,
"used": 0,
"inodes": 0,
"inodes_free": 0,
"inodes_used": 0,
"blocks": 0,
"block_size": 4096
}
]
获得帮助
要显示 duf 实用程序的帮助部分,请运行:
$ duf --help
样本输出:
Usage of duf:
-all
include pseudo, duplicate, inaccessible file systems
-hide-binds
hide bind mounts (default true)
-hide-fuse
hide fuse devices
-hide-local
hide local devices
-hide-loops
hide loop devices (default true)
-hide-network
hide network devices
-hide-special
hide special devices
-inodes
list inode information instead of block usage
-json
output all devices in JSON format
-output string
output fields: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem
-sort string
sort output by: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem (default "mountpoint")
-width uint
max output width
资源:
相关阅读:
- ‘du’ 命令的一些不错的替代方案
- Filelight – 可视化 Linux 系统上的磁盘使用情况
- 如何使用 Ncdu 检查 Linux 中的磁盘空间使用情况
- Agedu – 找出 Linux 中浪费的磁盘空间
- Duc – 检查和可视化磁盘使用情况的工具集
- 带有初学者示例的 df 命令教程
- 如何在 Linux 中使用 Lfs 列出文件系统
特色图片由 Picsaf Com 从 像素.