Use duf to check disk usage on Linux/macOS
You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose
Obtaining storage device usage information is a long-term operation of any desktop/server user. Duff Is a command line tool designed to enable Linux, macOS and BSD users to print “disk usage” in their terminal console. This tool is designed to uniformly output disk usage, obtain inode information, file system, mount point, type and other required commands. This article will guide you through the installation and use of duf utility.
Function of duf tool
- It has colorful and user-friendly output
- You can sort the results according to your needs
- Able to adjust the output according to the width of the terminal
- Group and filter equipment
- You can output JSON format to use with other tools
Install duf on Linux
There are many ways to install duf utility on a Linux machine.
Install using binary method
Download the latest binary files for Linux machines.
curl -s https://api.github.com/repos/muesli/duf/releases/latest | grep browser_download_url | grep linux_x86_64.tar.gz | cut -d '"' -f 4 | wget -i -
Unzip the downloaded archive.
tar xvf duf_*_linux_x86_64.tar.gz
Give the binary file an executable bit.
chmod a+x duf
Move the binary file to the /usr/local/bin directory.
sudo mv duf /usr/local/bin
Test whether the file is executable:
$ duf
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ 2 local devices │
├────────────┬───────┬──────┬───────┬───────────────────────────────┬──────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼───────┼──────┼───────┼───────────────────────────────┼──────┼────────────┤
│ / │ 37.4G │ 2.9G │ 32.9G │ [#...................] 7.8% │ ext4 │ /dev/sda1 │
│ /boot/efi │ 60.0M │ 2.5M │ 57.5M │ [....................] 4.2% │ vfat │ /dev/sda15 │
╰────────────┴───────┴──────┴───────┴───────────────────────────────┴──────┴────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 6 special devices │
├────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────────┼────────────┤
│ /dev │ 1.9G │ 0B │ 1.9G │ │ devtmpfs │ udev │
│ /dev/shm │ 1.9G │ 8.0K │ 1.9G │ [....................] 0.0% │ tmpfs │ tmpfs │
│ /run │ 384.0M │ 832.0K │ 383.2M │ [....................] 0.2% │ tmpfs │ tmpfs │
│ /run/lock │ 5.0M │ 0B │ 5.0M │ │ tmpfs │ tmpfs │
│ /run/user/0 │ 384.0M │ 0B │ 384.0M │ │ tmpfs │ tmpfs │
│ /sys/fs/cgroup │ 1.9G │ 0B │ 1.9G │ │ tmpfs │ tmpfs │
╰────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────────┴────────────╯
Install using package
Package installation is an alternative method.
Arch Linux / Manjaro:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
yay -S duf
curl -s https://api.github.com/repos/muesli/duf/releases/latest | grep browser_download_url | grep linux_amd64.deb | cut -d '"' -f 4 | wget -i -
sudo dpkg -i duf_*_linux_amd64.deb
CentOS / RHEL / Fedora:
curl -s https://api.github.com/repos/muesli/duf/releases/latest | grep browser_download_url | grep linux_amd64.rpm | cut -d '"' -f 4 | wget -i -
sudo rpm -Uvh duf_*_linux_amd64.rpm
Install duf on macOS
For macOS users, you can use Homebrew or MacPorts to complete the installation.
However, you need to install Homebrew or MacPorts depending on the method you want to use.
### Install Homebrew on macOS ###
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
You can check MacPorts installation Guide to the steps. The following command is used to install duf on macOS using brew.
$ brew install muesli/tap/duf
==> Tapping muesli/tap
Cloning into '/usr/local/Homebrew/Library/Taps/muesli/homebrew-tap'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 21 (delta 7), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (21/21), done.
Tapped 4 formulae (48 files, 31.6KB).
==> Installing duf from muesli/tap
==> Downloading https://github.com/muesli/duf/releases/download/v0.3.1/duf_0.3.1_Darwin_x86_64.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/297165998/52bd4f80-ffc5-11ea-9431-de9ad9d69000
######################################################################## 100.0%
🍺 /usr/local/Cellar/duf/0.3.1: 5 files, 2.5MB, built in 4 seconds
To install using MacPorts, use the following command.
$ sudo port selfupdate
$ sudo port install duf
Use duf command to check disk usage on Linux Apple system
The basic command usage is:
$ duf
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices │
├────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────┬──────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────┼──────────────┤
│ / │ 931.5G │ 10.5G │ 391.7G │ [....................] 1.1% │ apfs │ /dev/disk1s1 │
│ /System/Volumes/Data │ 931.5G │ 524.9G │ 391.7G │ [###########.........] 56.3% │ apfs │ /dev/disk1s2 │
│ /Volumes/VMware Fusion │ 1.2G │ 1.2G │ 80.0M │ [##################..] 93.7% │ hfs │ /dev/disk2s1 │
│ /private/var/vm │ 931.5G │ 3.7G │ 391.7G │ [....................] 0.4% │ apfs │ /dev/disk1s5 │
╰────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────┴──────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 special device │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────┤
│ /dev │ 347.5K │ 347.5K │ 0B │ [####################] 100.0% │ devfs │ devfs │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────╯
Display output when sorting by size.
$ duf --sort size
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices │
├────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────┬──────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────┼──────────────┤
│ /Volumes/VMware Fusion │ 1.2G │ 1.2G │ 80.0M │ [##################..] 93.7% │ hfs │ /dev/disk2s1 │
│ / │ 931.5G │ 10.5G │ 391.7G │ [....................] 1.1% │ apfs │ /dev/disk1s1 │
│ /System/Volumes/Data │ 931.5G │ 524.9G │ 391.7G │ [###########.........] 56.3% │ apfs │ /dev/disk1s2 │
│ /private/var/vm │ 931.5G │ 3.7G │ 391.7G │ [....................] 0.4% │ apfs │ /dev/disk1s5 │
╰────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────┴──────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 special device │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────┤
│ /dev │ 347.5K │ 347.5K │ 0B │ [####################] 100.0% │ devfs │ devfs │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────╯
List inode information instead of block usage:
$ duf --inodes
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices │
├────────────────────────┬────────────┬─────────┬────────────┬───────────────────────────────┬──────┬──────────────┤
│ MOUNTED ON │ INODES │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────────────┼────────────┼─────────┼────────────┼───────────────────────────────┼──────┼──────────────┤
│ / │ 9767978160 │ 488397 │ 9767489763 │ [....................] 0.0% │ apfs │ /dev/disk1s1 │
│ /System/Volumes/Data │ 9767978160 │ 1942488 │ 9766035672 │ [....................] 0.0% │ apfs │ /dev/disk1s2 │
│ /Volumes/VMware Fusion │ 4294967279 │ 4529 │ 4294962750 │ [....................] 0.0% │ hfs │ /dev/disk2s1 │
│ /private/var/vm │ 9767978160 │ 3 │ 9767978157 │ [....................] 0.0% │ apfs │ /dev/disk1s5 │
╰────────────────────────┴────────────┴─────────┴────────────┴───────────────────────────────┴──────┴──────────────╯
╭─────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 special device │
├────────────┬────────┬──────┬───────┬───────────────────────────────┬───────┬────────────┤
│ MOUNTED ON │ INODES │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼──────┼───────┼───────────────────────────────┼───────┼────────────┤
│ /dev │ 1215 │ 1215 │ 0 │ [####################] 100.0% │ devfs │ devfs │
╰────────────┴────────┴──────┴───────┴───────────────────────────────┴───────┴────────────╯
List all content (including pseudo, duplicate, and inaccessible file systems):
$ duf --all
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices │
├────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────┬──────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────┼──────────────┤
│ / │ 931.5G │ 10.5G │ 391.7G │ [....................] 1.1% │ apfs │ /dev/disk1s1 │
│ /System/Volumes/Data │ 931.5G │ 524.9G │ 391.7G │ [###########.........] 56.3% │ apfs │ /dev/disk1s2 │
│ /Volumes/VMware Fusion │ 1.2G │ 1.2G │ 80.0M │ [##################..] 93.7% │ hfs │ /dev/disk2s1 │
│ /private/var/vm │ 931.5G │ 3.7G │ 391.7G │ [....................] 0.4% │ apfs │ /dev/disk1s5 │
╰────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────┴──────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 special device │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────┤
│ /dev │ 347.5K │ 347.5K │ 0B │ [####################] 100.0% │ devfs │ devfs │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────╯
Sort by used capacity.
$ duf --sort used
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 4 local devices │
├────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────┬──────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────┼──────────────┤
│ /Volumes/VMware Fusion │ 1.2G │ 1.2G │ 80.0M │ [##################..] 93.7% │ hfs │ /dev/disk2s1 │
│ /private/var/vm │ 931.5G │ 3.7G │ 391.7G │ [....................] 0.4% │ apfs │ /dev/disk1s5 │
│ / │ 931.5G │ 10.5G │ 391.7G │ [....................] 1.1% │ apfs │ /dev/disk1s1 │
│ /System/Volumes/Data │ 931.5G │ 524.9G │ 391.7G │ [###########.........] 56.3% │ apfs │ /dev/disk1s2 │
╰────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────┴──────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────╮
│ 1 special device │
├────────────┬────────┬────────┬───────┬───────────────────────────────┬───────┬────────────┤
│ MOUNTED ON │ SIZE │ USED │ AVAIL │ USE% │ TYPE │ FILESYSTEM │
├────────────┼────────┼────────┼───────┼───────────────────────────────┼───────┼────────────┤
│ /dev │ 347.5K │ 347.5K │ 0B │ [####################] 100.0% │ devfs │ devfs │
╰────────────┴────────┴────────┴───────┴───────────────────────────────┴───────┴────────────╯
The valid keys for sorting are:
- size
- used
- it works
- usage
- Index node
- inodes_used
- inodes_avail
- inodes_usage
- Types of
- File system
- Mount point
Here is another example where some columns are hidden in the output:
$ duf --output mountpoint,size,usage,avail
╭──────────────────────────────────────────────────────────────────────────╮
│ 4 local devices │
├────────────────────────┬────────┬────────┬───────────────────────────────┤
│ MOUNTED ON │ SIZE │ AVAIL │ USE% │
├────────────────────────┼────────┼────────┼───────────────────────────────┤
│ / │ 931.5G │ 391.7G │ [....................] 1.1% │
│ /System/Volumes/Data │ 931.5G │ 391.7G │ [###########.........] 56.3% │
│ /Volumes/VMware Fusion │ 1.2G │ 80.0M │ [##################..] 93.7% │
│ /private/var/vm │ 931.5G │ 391.7G │ [....................] 0.4% │
╰────────────────────────┴────────┴────────┴───────────────────────────────╯
╭─────────────────────────────────────────────────────────────╮
│ 1 special device │
├────────────┬────────┬───────┬───────────────────────────────┤
│ MOUNTED ON │ SIZE │ AVAIL │ USE% │
├────────────┼────────┼───────┼───────────────────────────────┤
│ /dev │ 347.5K │ 0B │ [####################] 100.0% │
╰────────────┴────────┴───────┴───────────────────────────────╯
You can also use the -json command option to print the output in json format.
$ duf --json
Check out similar guides available on our website.
- Install wtfutil personal information dashboard for your terminal
- Top terminal-based monitoring tool for Linux
- Install Bashtop-Terminal Resource Monitor for Linux | macOS | FreeBSD
- How to copy and paste text content from Linux terminal
You can download this article in PDF format via the link below to support us.Download the guide in PDF formatClose