使用 duf 终端工具检查你的磁盘使用情况
duf du df
![](/data/attachment/album/202103/01/091533qkx95xomkzfmsdxo.jpg)



> 
> `duf` 是一个终端工具，旨在增强传统的 Linux 命令 `df` 和 `du`。它可以让你轻松地检查可用磁盘空间，对输出进行分类，并以用户友好的方式呈现。
> 
> 
> 


### duf：一个用 Golang 编写的跨平台磁盘使用情况工具


![](/data/attachment/album/202103/01/091542sgmflzc4fh4gzcrf.jpg)


在我知道这个工具之前，我更喜欢使用像 [Stacer](https://itsfoss.com/optimize-ubuntu-stacer/) 这样的 GUI 程序或者预装的 GNOME 磁盘使用情况程序来 [检查可用的磁盘空间](https://itsfoss.com/check-free-disk-space-linux/) 和系统的磁盘使用量。


不过，[duf](https://github.com/muesli/duf) 似乎是一个有用的终端工具，可以检查磁盘使用情况和可用空间，它是用 [Golang](https://golang.org/) 编写的。Abhishek 建议我试一试它，但我对它很感兴趣，尤其是考虑到我目前正在学习 Golang，真是太巧了!


无论你是终端大师还是只是一个对终端不适应的初学者，它都相当容易使用。当然，它比 [检查磁盘空间利用率命令 df](https://linuxhandbook.com/df-command/) 更容易理解。


在你把它安装到你的系统上之前，让我重点介绍一下它的一些主要功能和用法。


### duf 的特点


![](/data/attachment/album/202103/01/091543hd8ahk461m7ehk1m.jpg)


* 提供所有挂载设备的概览且易于理解。
* 能够指定目录/文件名并检查该挂载点的可用空间。
* 更改/删除输出中的列。
* 列出 [inode](https://linuxhandbook.com/inode-linux/) 信息。
* 输出排序。
* 支持 JSON 输出。
* 如果不能自动检测终端的主题，可以指定主题。


### 在 Linux 上安装和使用 duf


你可以在 [AUR](https://itsfoss.com/aur-arch-linux/) 中找到一个 Arch Linux 的软件包。如果你使用的是 [Nix 包管理器](https://github.com/NixOS/nixpkgs)，也可以找到一个包。


对于基于 Debian 的发行版和 RPM 包，你可以去它的 [GitHub 发布区](https://github.com/muesli/duf/releases) 中获取适合你系统的包。


它也适用于 Windows、Android、macOS 和 FreeBSD。


在我这里，我需要 [安装 DEB 包](https://itsfoss.com/install-deb-files-ubuntu/)，然后就可以使用了。安装好后，使用起来很简单，你只要输入：



```
duf

```

这应该会给你提供所有本地设备、已挂载的任何云存储设备以及任何其他特殊设备（包括临时存储位置等）的详细信息。


如果你想一目了然地查看所有 `duf` 的可用命令，你可以输入：



```
duf --help

```

![](/data/attachment/album/202103/01/091543tou8h66uzhqj6s6u.jpg)


例如，如果你只想查看本地连接设备的详细信息，而不是其他的，你只需要输入：



```
duf --only local

```

另一个例子是根据大小按特定顺序对输出进行排序，下面是你需要输入的内容：



```
duf --sort size

```

输出应该是像这样的：


![](/data/attachment/album/202103/01/091544d46wffdg1g40fv06.jpg)


你可以探索它的 [GitHub 页面](https://github.com/muesli/duf)，以获得更多关于额外命令和安装说明的信息。


* [下载 duf](https://github.com/muesli/duf)


### 结束语


我发现终端工具 `duf` 相当方便，可以在不需要使用 GUI 程序的情况下，随时查看可用磁盘空间或使用情况。


你知道有什么类似的工具吗？欢迎在下面的评论中告诉我你的想法。




---


via: <https://itsfoss.com/duf-disk-usage/>


作者：[Ankush Das](https://itsfoss.com/author/ankush/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
*Brief: duf is a terminal tool meant as an enhancement to the traditional “df” and “du” Linux commands. It lets you easily check for free disk space, sort the output, and present it in a user-friendly manner.*

## duf: A Cross-Platform disk usage utility written in Golang

![duf utility to analyze disk space](https://itsfoss.com/content/images/wordpress/2021/02/duf-screenshot.jpg)

Before I knew about this utility, I preferred using a GUI program like [Stacer](https://itsfoss.com/optimize-ubuntu-stacer/) or the pre-installed GNOME Disk usage app to [check free disk space](https://itsfoss.com/check-free-disk-space-linux/) and the disk usage numbers for my system.

However, [duf](https://github.com/muesli/duf) seems to be a useful terminal tool to check disk usage and free space that is written in [Golang](https://golang.org/). Even though Abhishek suggested me to give this a try, I found it more interesting, especially considering that I’m currently learning Golang, what a coincidence!

It is fairly easy to use no matter whether you are a terminal guru or just a beginner not comfortable with the terminal. It is certainly easier to understand than the [df command for checking disk space utilization](https://linuxhandbook.com/df-command/).

Let me highlight some of the key features and its usage before you get it installed on your system.

## Features of duf

![duf local](https://itsfoss.com/content/images/wordpress/2021/02/duf-local.jpg)

- Gives you an overview of all the devices mounted which is easy to understand
- Ability to specify a directory/file name and check free space for that mount point
- Change/Remove columns from the output
- List
[inode](https://linuxhandbook.com/inode-linux/)information - Sort the output
- JSON output supported
- Ability to specify the theme if it does not detect your terminal’s theme automatically

## Installing & Using duf on Linux

You can find a package for Arch Linux in [AUR](https://itsfoss.com/aur-arch-linux/). There’s also a package available if you’re using the [Nix package manager](https://github.com/NixOS/nixpkgs).

For Debian-based distros and RPM packages, you can go to its [GitHub releases section](https://github.com/muesli/duf/releases) and grab the package suitable for your system.

It’s also available for Windows, Android, macOS, and FreeBSD as well.

In my case, I had to [install the DEB package](https://itsfoss.com/install-deb-files-ubuntu/), and it was good to go. Once you set it up, using it is quite simple, all you have to do is type in:

`duf`


This should give you the details for all the local devices, any cloud storage devices mounted, and any other special devices (that includes temporary storage locations and more).

If you want to take a look at all the available commands using **duf** at a glance, you can type in:

`duf --help`


![duf command option](https://itsfoss.com/content/images/wordpress/2021/02/duf-commands.jpg)

For instance, if you just want to see the details of the local devices connected and nothing else, all you have to type is:

`duf --only local`


Another example would be sorting the output based on the size in a particular order, here’s what you need to type:

`duf --sort size`


And, the output should look like:

![duf sort example](https://itsfoss.com/content/images/wordpress/2021/02/duf-sort-example.jpg)

You can explore its [GitHub page](https://github.com/muesli/duf) for more information on additional commands and installation instructions.

## Closing Thoughts

I find the terminal tool ‘duf’ quite handy to keep an eye on the free disk space or the usage stats without needing to use a GUI program.

Is there anything similar to this tool that you know of? Feel free to let me know your thoughts in the comments down below.