Home Command line utilities How To View Disk Usage With Duf On Linux And Unix

How To View Disk Usage With Duf On Linux And Unix

By sk
Published: Updated: 7.2K views

The most commonly used application to view the disk usage in Linux and Unix is du. The du, stands for disk usage, is being widely used to find out which files and directories have occupied the most disk space. There are also many alternative command line and graphical tools exists to accomplish this task. We have already covered some of them and posted here (links are given at the end) in our blog in the past. Today, we will yet another disk usage checker named duf.

What is Duf?

Duf is a command line utility to find disk usage in Linux and Unix-like systems. It displays the disk usage details in a nice tabular-column and user-friendly layout. You can even get the disk usage output in JSON format as well.

If the output exceeds the visible part of the screen, it automatically adjusts the terminal's width. You can sort the results by total size, filesystem type, used and free space, mount point and inodes. It is also possible to show, hide and exclude specific device details from the output.

Duf is the contraction of disk usage/free. It is also considered as a better alternative to the traditional df command.

Duf is an open source application written in Go programming language and released under MIT license. It works under GNU/Linux, BSD and Mac OS.

Install Duf on Linux

Currently, Duf has been packaged for Arch-based, DEB-based and RPM-based Linux operating systems.

Duf is available in AUR. If you are using Arch Linux or any arch variants, you can install it using the AUR helper programs, for example Paru or Yay.

$ paru -S duf

Or,

$ yay -S duf

On DEB-based systems such as Debian, Ubuntu, Linux Mint, download the .deb binary installation file from the releases page and install it using your system's package manager.

$ sudo apt install gdebi
$ sudo gdebi duf_0.3.1_linux_amd64.deb

On RPM-based systems such as RHEL, CentOS, Fedora, download the .rpm binary file and install it using command:

$ sudo rpm -Uvh duf_0.3.1_linux_amd64.rpm

Install Duf from source

We can also build and install duf from source. Make sure you have installed GO language on your system.

Git clone the duf repository:

$ git clone https://github.com/muesli/duf.git

The above command will clone the contents of duf online repository in a local directory named "duf". Go to that directory:

$ cd duf

Compile and install it using command:

$ go build

View Disk Usage With Duf On Linux And Unix

Finding disk space usage with duf is easy!

All you have to do is just run the duf command without any options like below:

$ duf

Sample output:

╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 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      │
╰────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────────┴────────────╯
View Disk Usage With Duf On Linux And Unix
View Disk Usage With Duf On Linux And Unix

As you can see in the above output, Duf lists the following details in a nice tabular-column format:

  • total number of mounted devices,
  • mount point,
  • total size of the root partition,
  • total size of used and free disk space,
  • total disk usage in percentage,
  • filesystem type,
  • filesystem name etc.

To display all details including pseudo, duplicate, and inaccessible file systems, run:

$ duf --all

Sample output:

╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 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     │
╰─────────────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴─────────────┴─────────────╯

Exclude specific device details from the output

Sometimes, you might want to exclude some details from the output. For instance, the following command will exclude the details of special devices (E.g. /run/lock, /sys/fs/bpf).

$ duf --hide-special

This will display the disk usage details of the local devices only i.e. eliminate the special devices from the output:

╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 local device                                                                           │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │   SIZE │   USED │ AVAIL │              USE%             │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼──────┼────────────┤
│ /          │ 457.4G │ 412.0G │ 22.1G │ [##################..]  90.1% │ ext4 │ /dev/sda1  │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴──────┴────────────╯

The other supported options are:

  • --hide-local
  • --hide-network
  • --hide-fuse
  • --hide-loops
  • --hide-binds

Sort output

We can display the disk usage details sorted by various parameters such as: 

  • mountpoint
  • size
  • used
  • avail
  • usage
  • inodes
  • inodes_used
  • inodes_avail
  • inodes_usage
  • type
  • filesystem etc.

For instance, to sort the output by size, use this command:

$ duf --sort size

Sort output by filesystem:

$ duf --sort filesystem

Show or hide specific columns

Similar to exclude some device details from the output, we can also show or hide a specific column from the output.

The following command will show the output of mountpoint, size and usage columns only:

$ duf --output mountpoint,size,usage

Sample output:

╭─────────────────────────────────────────────────────╮
│ 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 │                               │
╰────────────────┴────────┴───────────────────────────────╯

The list of supported options are:

  • mountpoint
  • size
  • used
  • avail
  • usage
  • inodes
  • inodes_used
  • inodes_avail
  • inodes_usage
  • type
  • filesystem.

Display inode details

If you want to list inode information instead of block usage, run this command:

$ duf --inodes

Display disk usage output in JSON format

Instead of displaying the output in tabular-column format, we can display it in JSON format.

To do so, run:

$ duf --json

Sample output:

[
 {
  "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
 }
]

Getting help

To display help section of duf utility, run:

$ duf --help

Sample output:

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

Resource:

Featured image by Picsaf Com from Pexels.

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More