Thursday, October 14
Shadow

Duf Utility In Linux To View Disk Usage

The most commonly used application to view disk usage in Linux is du. Du stands for disk usage, is being widely used to find out which files and directories have occupied the most disk space. There are many other command lines and graphical tools that exist to accomplish this task. Today, we will cover a disk usage checker named duf.

Duf (disk usage/free) is a command-line utility to find disk usage in Linux and Unix 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 Installation

On DEB-based systems like Ubuntu, Linux Mint, Debian download the .deb package from the source page and install using the 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 package from the above source page and install using RedHat package manager.

[root@linuxhawks ~]# rpm -ivh duf_0.6.0_linux_amd64.rpm
 Preparing…          ################################# [100%]
 Updating / installing…
    1:duf-0:0.6.0-1  ################################# [100%]

Use Duf On CLI

Just run duf command without any options.

[root@linuxhawks ~]# duf

Duf lists the following details in a tabular-column format:

  • Number of mounted devices
  • Mount point
  • Size of the root partition
  • Size of used and free disk space
  • Disk usage in percentage
  • File system type etc

Duf Help

For help with duf, you can use below command:

[root@linuxhawks ~]# duf -help

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

[root@linuxhawks ~]# duf -all
 ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │ 6 local devices                                                                                                 │
 ├──────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬────────────┬──────────────┤
 │ MOUNTED ON               │   SIZE │   USED │  AVAIL │              USE%             │ TYPE       │ FILESYSTEM   │
 ├──────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼────────────┼──────────────┤
 │ /                        │  50.0G │   5.1G │  44.9G │ [##………………]  10.1% │ xfs        │ /dev/cl/root │
 │ /boot                    │ 975.9M │ 326.0M │ 582.7M │ [######…………..]  33.4% │ ext4       │ /dev/sda1    │
 │ /home                    │  45.0G │ 461.3M │  44.6G │ [………………..]   1.0% │ xfs        │ /dev/cl/home │
 │ /sys/fs/fuse/connections │     0B │     0B │     0B │                               │ fusectl    │ fusectl      │
 │ /sys/fs/selinux          │     0B │     0B │     0B │                               │ selinuxfs  │ selinuxfs    │
 │ /var/lib/nfs/rpc_pipefs  │     0B │     0B │     0B │                               │ rpc_pipefs │ sunrpc       │
 ╰──────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴────────────┴──────────────╯
 ╭──────────────────────────────────────────────────────────────────────────────╮
 │ 1 fuse device                                                                │
 ├──────────────────┬──────┬──────┬───────┬──────┬─────────────────┬────────────┤
 │ MOUNTED ON       │ SIZE │ USED │ AVAIL │ USE% │ TYPE            │ FILESYSTEM │
 ├──────────────────┼──────┼──────┼───────┼──────┼─────────────────┼────────────┤
 │ /run/user/0/gvfs │   0B │   0B │    0B │      │ fuse.gvfsd-fuse │ gvfsd-fuse │
 ╰──────────────────┴──────┴──────┴───────┴──────┴─────────────────┴────────────╯
 ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │ 31 special devices                                                                                                    │
 ├─────────────────────────────────┬────────┬───────┬────────┬───────────────────────────────┬─────────────┬─────────────┤
 │ MOUNTED ON                      │   SIZE │  USED │  AVAIL │              USE%             │ TYPE        │ FILESYSTEM  │
 ├─────────────────────────────────┼────────┼───────┼────────┼───────────────────────────────┼─────────────┼─────────────┤
 │ /dev                            │ 835.1M │    0B │ 835.1M │                               │ devtmpfs    │ devtmpfs    │
 │ /dev/hugepages                  │     0B │    0B │     0B │                               │ hugetlbfs   │ hugetlbfs   │
 │ /dev/mqueue                     │     0B │    0B │     0B │                               │ mqueue      │ mqueue      │
 │ /dev/pts                        │     0B │    0B │     0B │                               │ devpts      │ devpts      │
 │ /dev/shm                        │ 862.8M │    0B │ 862.8M │                               │ tmpfs       │ tmpfs       │
 │ /proc                           │     0B │    0B │     0B │                               │ proc        │ proc        │
 │ /proc/sys/fs/binfmt_misc        │     0B │    0B │     0B │                               │ binfmt_misc │ binfmt_misc │
 │ /proc/sys/fs/binfmt_misc        │     0B │    0B │     0B │                               │ autofs      │ systemd-1   │
 │ /run                            │ 862.8M │ 17.5M │ 845.4M │ [………………..]   2.0% │ tmpfs       │ tmpfs       │
 │ /run/user/0                     │ 172.6M │ 24.0K │ 172.5M │ [………………..]   0.0% │ tmpfs       │ tmpfs       │
 │ /run/user/42                    │ 172.6M │ 16.0K │ 172.6M │ [………………..]   0.0% │ tmpfs       │ tmpfs       │
 │ /sys                            │     0B │    0B │     0B │                               │ sysfs       │ sysfs       │
 │ /sys/fs/bpf                     │     0B │    0B │     0B │                               │ bpf         │ bpf         │
 │ /sys/fs/cgroup                  │ 862.8M │    0B │ 862.8M │                               │ 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/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     │ none        │
 ╰─────────────────────────────────┴────────┴───────┴────────┴───────────────────────────────┴─────────────┴─────────────╯

Print Inodes Information On CLI

To get the inodes information instead of block usage, you can simply use the below command:

[root@linuxhawks ~]# duf -inodes

Exclude Specific Device Details From The Output

If you want to exclude some details from the output, you can use option –hide special with duf command.

[root@linuxhawks ~]# duf -hide special

Sort Output

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

  • Size
  • Mountpoint
  • Used
  • Avail
  • Usage
  • Inodes
  • Type etc

To sort the output by size, use below command:

[root@linuxhawks ~]# duf -sort size

Show Or Hide Specific Column

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 mount point, size, use%, and filesystem column only.

[root@linuxhawks ~]# duf -output mountpoint,size,usage,filesystem

Print Disk Usage In Json Format

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

[root@linuxhawks ~]# duf -json

Source: https://github.com/muesli/duf

Leave a Reply

Your email address will not be published. Required fields are marked *

error

Enjoy this blog? Please spread the word :)