Skip to main content

How do you check disk usage in Linux? I’m sure that is a question many of us have wondered especially when first learning Linux. There are many tools out there that can help us view this information about our system. In my opinion, a lot of them just look ugly, simple to understand but still ugly – I’m a man of style! So that is why we’re going to take a look at the duf command found on GitHub. It is very informative, written in GoLang and has a few handy features some of you might find useful like exporting data as JSON.

Installing DUF

If you’re lucky, duf might be in your local repository but sadly for me on Ubuntu 20.04 LTS, it was not. So lets go over installing it from the repository and manually downloading the package.

If the package is not in your repository, then head over to the releases page to manually download the right package for your system and architecture from the GitHub releases page.

Ubuntu/Debian

sudo apt install duf

Arch/Garuda

sudo pacman -Sy duf

Fedora/RHEL

sudo dnf install duf

Basic Usage

At the very most basic level, simply run the command duf and you will get the following output.

╭─────────────────────────────────────────────────────────────────────────────────────────╮
│ 2 local devices                                                                         │
├────────────┬────────┬──────┬────────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │   SIZE │ USED │  AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼────────┼──────┼────────┼───────────────────────────────┼──────┼────────────┤
│ /          │  19.1G │ 6.9G │  11.1G │ [#######.............]  36.4% │ ext4 │ /dev/vda5  │
│ /boot/efi  │ 511.0M │ 4.0K │ 511.0M │ [....................]   0.0% │ vfat │ /dev/vda1  │
╰────────────┴────────┴──────┴────────┴───────────────────────────────┴──────┴────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                                │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │   SIZE │  USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev           │   1.9G │    0B │   1.9G │                               │ devtmpfs │ udev       │
│ /dev/shm       │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
│ /run           │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs    │ tmpfs      │
│ /run/lock      │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run/user/1001 │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴──────────┴────────────╯

Doesn’t that just look pretty?

Checking Directory/Mount Usage

For most users the default output from duf should be more than enough especially if you’re only interested in usage at-a-glance. So on the machine I’m working on, I have added 2 additional drives of 5G each. Notice how in the last output, you do not see them. This is because we first have to mount them so I will do that now and re-run duf.

╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices                                                                          │
├────────────┬────────┬───────┬────────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │   SIZE │  USED │  AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼────────┼───────┼────────┼───────────────────────────────┼──────┼────────────┤
│ /          │  19.1G │  6.9G │  11.1G │ [#######.............]  36.4% │ ext4 │ /dev/vda5  │
│ /boot/efi  │ 511.0M │  4.0K │ 511.0M │ [....................]   0.0% │ vfat │ /dev/vda1  │
│ /mnt/a     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdb1  │
│ /mnt/b     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdc1  │
╰────────────┴────────┴───────┴────────┴───────────────────────────────┴──────┴────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                                │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │   SIZE │  USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev           │   1.9G │    0B │   1.9G │                               │ devtmpfs │ udev       │
│ /dev/shm       │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
│ /run           │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs    │ tmpfs      │
│ /run/lock      │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run/user/1001 │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴──────────┴────────────╯

As you can see under local devices, I now have /mnt/a and /mnt/b. Now that we know where they are mounted, lets check for that mount usage alone.

linuxman@ubuntu:~$ duf /mnt/a
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ 1 local device                                                                        │
├────────────┬──────┬───────┬───────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │ SIZE │  USED │ AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼──────┼───────┼───────┼───────────────────────────────┼──────┼────────────┤
│ /mnt/a     │ 4.9G │ 20.0M │  4.6G │ [....................]   0.4% │ ext4 │ /dev/vdb1  │
╰────────────┴──────┴───────┴───────┴───────────────────────────────┴──────┴────────────╯

Little note about duf is that it cannot be used to check disk usage of a directory/file. If you run duf on separate directories but they are part of the same filesystem, then the output will show the filesystem of both directories. It’s still kind of neat!

Checking Misc Mounts

What about loop devices? Thought I forgot about those didn’t ya? While I have not taken my memory pills in a while (swallows 3), I still remembered there is a way to check for other mount types on the system. If you have a disk image mounted or maybe (God forbid) a snap package mounted, you can check them by using the --all switch.

linuxman@ubuntu:~$ duf --all
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 14 local devices                                                                                                │
├──────────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON                   │   SIZE │   USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├──────────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /                            │  19.1G │   6.9G │  11.1G │ [#######.............]  36.4% │ ext4     │ /dev/vda5  │
│ /boot/efi                    │ 511.0M │   4.0K │ 511.0M │ [....................]   0.0% │ vfat     │ /dev/vda1  │
│ /mnt/a                       │   4.9G │  20.0M │   4.6G │ [....................]   0.4% │ ext4     │ /dev/vdb1  │
│ /mnt/b                       │   4.9G │  20.0M │   4.6G │ [....................]   0.4% │ ext4     │ /dev/vdc1  │
│ /snap/bare/5                 │ 128.0K │ 128.0K │     0B │ [####################] 100.0% │ squashfs │ /dev/loop0 │
│ /snap/core20/1328            │  62.0M │  62.0M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop1 │
│ /snap/core20/1518            │  62.0M │  62.0M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop3 │
│ /snap/gnome-3-38-2004/106    │ 254.1M │ 254.1M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop2 │
│ /snap/gnome-3-38-2004/99     │ 248.9M │ 248.9M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop4 │
│ /snap/gtk-common-themes/1519 │  65.2M │  65.2M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop5 │
│ /snap/gtk-common-themes/1534 │  81.4M │  81.4M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop6 │
│ /snap/snap-store/558         │  54.2M │  54.2M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop8 │
│ /snap/snapd/14978            │  43.6M │  43.6M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop9 │
│ /snap/snapd/16010            │  47.0M │  47.0M │     0B │ [####################] 100.0% │ squashfs │ /dev/loop7 │
╰──────────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────────┴────────────╯
╭─────────────────────────────────────────────────────────────────────────────────╮
│ 1 fuse device                                                                   │
├─────────────────────┬──────┬──────┬───────┬──────┬─────────────────┬────────────┤
│ MOUNTED ON          │ SIZE │ USED │ AVAIL │ USE% │ TYPE            │ FILESYSTEM │
├─────────────────────┼──────┼──────┼───────┼──────┼─────────────────┼────────────┤
│ /run/user/1000/gvfs │   0B │   0B │    0B │      │ fuse.gvfsd-fuse │ gvfsd-fuse │
╰─────────────────────┴──────┴──────┴───────┴──────┴─────────────────┴────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 35 special devices                                                                                                    │
├─────────────────────────────────┬────────┬───────┬────────┬───────────────────────────────┬─────────────┬─────────────┤
│ MOUNTED ON                      │   SIZE │  USED │  AVAIL │              USE%             │ TYPE        │ FILESYSTEM  │
├─────────────────────────────────┼────────┼───────┼────────┼───────────────────────────────┼─────────────┼─────────────┤
│ /dev                            │   1.9G │    0B │   1.9G │                               │ 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                        │   1.9G │    0B │   1.9G │                               │ tmpfs       │ tmpfs       │
│ /proc                           │     0B │    0B │     0B │                               │ proc        │ proc        │
│ /proc/sys/fs/binfmt_misc        │     0B │    0B │     0B │                               │ autofs      │ systemd-1   │
│ /proc/sys/fs/binfmt_misc        │     0B │    0B │     0B │                               │ binfmt_misc │ binfmt_misc │
│ /run                            │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs       │ tmpfs       │
│ /run/lock                       │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs       │ tmpfs       │
│ /run/user/1000                  │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs       │ tmpfs       │
│ /run/user/1001                  │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs       │ tmpfs       │
│ /sys                            │     0B │    0B │     0B │                               │ sysfs       │ sysfs       │
│ /sys/fs/bpf                     │     0B │    0B │     0B │                               │ bpf         │ none        │
│ /sys/fs/cgroup                  │   1.9G │    0B │   1.9G │                               │ 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/misc             │     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/fuse/connections        │     0B │    0B │     0B │                               │ fusectl     │ fusectl     │
│ /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     │
╰─────────────────────────────────┴────────┴───────┴────────┴───────────────────────────────┴─────────────┴─────────────╯

So here we see that we have information about all kinds of mounted devices on our system which most of us probably don’t really care about. Still, its a nice-to-have kind of thing!

Checking Inodes

Wait… What are inodes in Linux? Inodes in the filesystem is where the metadata of the actual data is stored, but not the actual data. You can think of it as a database that indexes information about data, while the data is actually stored somewhere else. You index the database and know where to find the data, kind of like a map!

So how do we check for inodes? Well, simply by using the -inodes switch!

linuxman@ubuntu:~$ duf -inodes
╭─────────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices                                                                             │
├────────────┬─────────┬────────┬─────────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │  INODES │  IUSED │  IAVAIL │             IUSE%             │ TYPE │ FILESYSTEM │
├────────────┼─────────┼────────┼─────────┼───────────────────────────────┼──────┼────────────┤
│ /          │ 1277952 │ 176606 │ 1101346 │ [##..................]  13.8% │ ext4 │ /dev/vda5  │
│ /boot/efi  │       0 │      0 │       0 │                               │ vfat │ /dev/vda1  │
│ /mnt/a     │  327680 │     11 │  327669 │ [....................]   0.0% │ ext4 │ /dev/vdb1  │
│ /mnt/b     │  327680 │     11 │  327669 │ [....................]   0.0% │ ext4 │ /dev/vdc1  │
╰────────────┴─────────┴────────┴─────────┴───────────────────────────────┴──────┴────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                                │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │ INODES │ IUSED │ IAVAIL │             IUSE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev           │ 493578 │   475 │ 493103 │ [....................]   0.1% │ devtmpfs │ udev       │
│ /dev/shm       │ 502549 │     1 │ 502548 │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run           │ 502549 │   846 │ 501703 │ [....................]   0.2% │ tmpfs    │ tmpfs      │
│ /run/lock      │ 502549 │     5 │ 502544 │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │ 502549 │    39 │ 502510 │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run/user/1001 │ 502549 │    78 │ 502471 │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │ 502549 │    19 │ 502530 │ [....................]   0.0% │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴──────────┴────────────╯

Now, as interesting as inodes are, we won’t be discussing them in detail here. However, from the output we can see our total available, used and remaining inodes on each mount/filesystem.

Filtering with DUF

Only Switches

What if you want to see only a certain type of device? Perhaps all of your snap mounts? We can do this using the switches -only, -only-mp, -only-fs. Lets first display only local devices.

linuxman@ubuntu:~$ duf -only local
╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices                                                                          │
├────────────┬────────┬───────┬────────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │   SIZE │  USED │  AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼────────┼───────┼────────┼───────────────────────────────┼──────┼────────────┤
│ /          │  19.1G │  6.9G │  11.1G │ [#######.............]  36.4% │ ext4 │ /dev/vda5  │
│ /boot/efi  │ 511.0M │  4.0K │ 511.0M │ [....................]   0.0% │ vfat │ /dev/vda1  │
│ /mnt/a     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdb1  │
│ /mnt/b     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdc1  │
╰────────────┴────────┴───────┴────────┴───────────────────────────────┴──────┴────────────╯

If we compare this to the default output, we see that only our local devices are displayed as expected.

Now let’s try filtering only mount points with a wildcard to list our snap mounts.

linuxman@ubuntu:~$ duf --all -only-mp '/snap/*'
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 10 local devices                                                                                               │
├──────────────────────────────┬────────┬────────┬───────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON                   │   SIZE │   USED │ AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├──────────────────────────────┼────────┼────────┼───────┼───────────────────────────────┼──────────┼────────────┤
│ /snap/bare/5                 │ 128.0K │ 128.0K │    0B │ [####################] 100.0% │ squashfs │ /dev/loop0 │
│ /snap/core20/1328            │  62.0M │  62.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop1 │
│ /snap/core20/1518            │  62.0M │  62.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop3 │
│ /snap/gnome-3-38-2004/106    │ 254.1M │ 254.1M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop2 │
│ /snap/gnome-3-38-2004/99     │ 248.9M │ 248.9M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop4 │
│ /snap/gtk-common-themes/1519 │  65.2M │  65.2M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop5 │
│ /snap/gtk-common-themes/1534 │  81.4M │  81.4M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop6 │
│ /snap/snap-store/558         │  54.2M │  54.2M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop8 │
│ /snap/snapd/14978            │  43.6M │  43.6M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop9 │
│ /snap/snapd/16010            │  47.0M │  47.0M │    0B │ [####################] 100.0% │ squashfs │ /dev/loop7 │
╰──────────────────────────────┴────────┴────────┴───────┴───────────────────────────────┴──────────┴────────────╯

Notice that here we also specified the --all switch before filtering the mount point. This is because by default, duf will filter the default output. So if your target mount point/filesystem only appears when using the –all switch, then you have to specify that first.

Finally let’s display only a certain filesystem type, so we’re going to test this out with tmpfs.

linuxman@ubuntu:~$ duf -only-fs tmpfs
╭───────────────────────────────────────────────────────────────────────────────────────────────╮
│ 6 special devices                                                                             │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬───────┬────────────┤
│ MOUNTED ON     │   SIZE │  USED │  AVAIL │              USE%             │ TYPE  │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼───────┼────────────┤
│ /dev/shm       │   1.9G │    0B │   1.9G │                               │ tmpfs │ tmpfs      │
│ /run           │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs │ tmpfs      │
│ /run/lock      │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs │ tmpfs      │
│ /run/user/1000 │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs │ tmpfs      │
│ /run/user/1001 │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs │ tmpfs      │
│ /sys/fs/cgroup │   1.9G │    0B │   1.9G │                               │ tmpfs │ tmpfs      │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴───────┴────────────╯

Hide Switches

Omar, I want to see everything except certain mounts/filesystems… what do? Well you’re in luck because duf can do that too! duf has -hide, -hide-mp, and -hide-fs. So let’s first hide local devices from the output.

linuxman@ubuntu:~$ duf -hide local
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                                │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │   SIZE │  USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev           │   1.9G │    0B │   1.9G │                               │ devtmpfs │ udev       │
│ /dev/shm       │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
│ /run           │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs    │ tmpfs      │
│ /run/lock      │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run/user/1001 │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴──────────┴────────────╯

See? Now we only receive our special devices and left out local, as expected.

Now lets hide all of our snap mounts because no one cares.

linuxman@ubuntu:~$ duf --all -hide-mp '/snap/*'
╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices                                                                          │
├────────────┬────────┬───────┬────────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │   SIZE │  USED │  AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼────────┼───────┼────────┼───────────────────────────────┼──────┼────────────┤
│ /          │  19.1G │  6.9G │  11.1G │ [#######.............]  36.4% │ ext4 │ /dev/vda5  │
│ /boot/efi  │ 511.0M │  4.0K │ 511.0M │ [....................]   0.0% │ vfat │ /dev/vda1  │
│ /mnt/a     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdb1  │
│ /mnt/b     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdc1  │
╰────────────┴────────┴───────┴────────┴───────────────────────────────┴──────┴────────────╯
╭─────────────────────────────────────────────────────────────────────────────────╮
│ 1 fuse device                                                                   │
├─────────────────────┬──────┬──────┬───────┬──────┬─────────────────┬────────────┤
│ MOUNTED ON          │ SIZE │ USED │ AVAIL │ USE% │ TYPE            │ FILESYSTEM │
├─────────────────────┼──────┼──────┼───────┼──────┼─────────────────┼────────────┤
│ /run/user/1000/gvfs │   0B │   0B │    0B │      │ fuse.gvfsd-fuse │ gvfsd-fuse │
╰─────────────────────┴──────┴──────┴───────┴──────┴─────────────────┴────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 35 special devices                                                                                                    │
├─────────────────────────────────┬────────┬───────┬────────┬───────────────────────────────┬─────────────┬─────────────┤
│ MOUNTED ON                      │   SIZE │  USED │  AVAIL │              USE%             │ TYPE        │ FILESYSTEM  │
├─────────────────────────────────┼────────┼───────┼────────┼───────────────────────────────┼─────────────┼─────────────┤
│ /dev                            │   1.9G │    0B │   1.9G │                               │ 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                        │   1.9G │    0B │   1.9G │                               │ tmpfs       │ tmpfs       │
│ /proc                           │     0B │    0B │     0B │                               │ proc        │ proc        │
│ /proc/sys/fs/binfmt_misc        │     0B │    0B │     0B │                               │ autofs      │ systemd-1   │
│ /proc/sys/fs/binfmt_misc        │     0B │    0B │     0B │                               │ binfmt_misc │ binfmt_misc │
│ /run                            │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs       │ tmpfs       │
│ /run/lock                       │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs       │ tmpfs       │
│ /run/user/1000                  │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs       │ tmpfs       │
│ /run/user/1001                  │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs       │ tmpfs       │
│ /sys                            │     0B │    0B │     0B │                               │ sysfs       │ sysfs       │
│ /sys/fs/bpf                     │     0B │    0B │     0B │                               │ bpf         │ none        │
│ /sys/fs/cgroup                  │   1.9G │    0B │   1.9G │                               │ 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/misc             │     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/fuse/connections        │     0B │    0B │     0B │                               │ fusectl     │ fusectl     │
│ /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     │
╰─────────────────────────────────┴────────┴───────┴────────┴───────────────────────────────┴─────────────┴─────────────╯

And just like that, snap is nowhere to be found, yay! Just like before, we have to specify --all in order for it to be hidden from the output.

And finally we will hide all of our cgroup mounts from all output. Wait, wait, wait… I also don’t want to see any squashfs and tmpfs… So I’m going to specify multiple filesystems I don’t care about.

linuxman@ubuntu:~$ duf --all -hide-fs cgroup,tmpfs,squashfs
╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices                                                                          │
├────────────┬────────┬───────┬────────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │   SIZE │  USED │  AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼────────┼───────┼────────┼───────────────────────────────┼──────┼────────────┤
│ /          │  19.1G │  6.9G │  11.1G │ [#######.............]  36.4% │ ext4 │ /dev/vda5  │
│ /boot/efi  │ 511.0M │  4.0K │ 511.0M │ [....................]   0.0% │ vfat │ /dev/vda1  │
│ /mnt/a     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdb1  │
│ /mnt/b     │   4.9G │ 20.0M │   4.6G │ [....................]   0.4% │ ext4 │ /dev/vdc1  │
╰────────────┴────────┴───────┴────────┴───────────────────────────────┴──────┴────────────╯
╭─────────────────────────────────────────────────────────────────────────────────╮
│ 1 fuse device                                                                   │
├─────────────────────┬──────┬──────┬───────┬──────┬─────────────────┬────────────┤
│ MOUNTED ON          │ SIZE │ USED │ AVAIL │ USE% │ TYPE            │ FILESYSTEM │
├─────────────────────┼──────┼──────┼───────┼──────┼─────────────────┼────────────┤
│ /run/user/1000/gvfs │   0B │   0B │    0B │      │ fuse.gvfsd-fuse │ gvfsd-fuse │
╰─────────────────────┴──────┴──────┴───────┴──────┴─────────────────┴────────────╯
╭───────────────────────────────────────────────────────────────────────────────────╮
│ 16 special devices                                                                │
├──────────────────────────┬──────┬──────┬───────┬──────┬─────────────┬─────────────┤
│ MOUNTED ON               │ SIZE │ USED │ AVAIL │ USE% │ TYPE        │ FILESYSTEM  │
├──────────────────────────┼──────┼──────┼───────┼──────┼─────────────┼─────────────┤
│ /dev                     │ 1.9G │   0B │  1.9G │      │ devtmpfs    │ udev        │
│ /dev/hugepages           │   0B │   0B │    0B │      │ hugetlbfs   │ hugetlbfs   │
│ /dev/mqueue              │   0B │   0B │    0B │      │ mqueue      │ mqueue      │
│ /dev/pts                 │   0B │   0B │    0B │      │ devpts      │ devpts      │
│ /proc                    │   0B │   0B │    0B │      │ proc        │ proc        │
│ /proc/sys/fs/binfmt_misc │   0B │   0B │    0B │      │ autofs      │ systemd-1   │
│ /proc/sys/fs/binfmt_misc │   0B │   0B │    0B │      │ binfmt_misc │ binfmt_misc │
│ /sys                     │   0B │   0B │    0B │      │ sysfs       │ sysfs       │
│ /sys/fs/bpf              │   0B │   0B │    0B │      │ bpf         │ none        │
│ /sys/fs/cgroup/unified   │   0B │   0B │    0B │      │ cgroup2     │ cgroup2     │
│ /sys/fs/fuse/connections │   0B │   0B │    0B │      │ fusectl     │ fusectl     │
│ /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     │
╰──────────────────────────┴──────┴──────┴───────┴──────┴─────────────┴─────────────╯

That’s more like it! You can indeed pass multiple device types, mount points and filesystems to hide/show in comma separated form.

Sorting DUF Output

I shall leave you off with one more useful trick duf provides and that is being able to sort the output based on certain conditions. Granted you are not able to create your own conditions using regex or something special like you can with awk or ps. But since disk usage is our only concern when using duf, it does it well enough!

You can use the -sort switch to re-order the output based on mountpoint, size, used, avail, usage, inodes and other different options. For our example, let’s say we want to sort our special devices based on availability.

linuxman@ubuntu:~$ duf -only special -sort avail
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 7 special devices                                                                                │
├────────────────┬────────┬───────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON     │   SIZE │  USED │  AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
├────────────────┼────────┼───────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /run/lock      │   5.0M │  4.0K │   5.0M │ [....................]   0.1% │ tmpfs    │ tmpfs      │
│ /run           │ 392.6M │  1.4M │ 391.2M │ [....................]   0.4% │ tmpfs    │ tmpfs      │
│ /run/user/1001 │ 392.6M │ 20.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /run/user/1000 │ 392.6M │  8.0K │ 392.6M │ [....................]   0.0% │ tmpfs    │ tmpfs      │
│ /dev           │   1.9G │    0B │   1.9G │                               │ devtmpfs │ udev       │
│ /dev/shm       │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
│ /sys/fs/cgroup │   1.9G │    0B │   1.9G │                               │ tmpfs    │ tmpfs      │
╰────────────────┴────────┴───────┴────────┴───────────────────────────────┴──────────┴────────────╯

There are a couple more nice switches to use from our beloved duf, but we’re here to keep it simple and point out the most useful! Check out their Github page which has more info on the command or if you want to just poke around, sneak in there the --help switch and figure it out 😉

Leave a Reply