5

duf - Disk Usage/Free Utility for Linux, BSD, macOS & Windows - nixCraft

 3 years ago
source link: https://www.cyberciti.biz/open-source/command-line-hacks/duf-disk-usage-free-utility-for-linux-bsd-macos-windows/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

duf – Disk Usage/Free Utility for Linux, BSD, macOS & Windows

Author: Vivek Gite Last updated: January 16, 2021 2 comments


We use the df command to show how much disk space is free on mounted file systems in Linux, macOS, and Unix-like systems. We also have the du command to estimate file space usage. We now have another fancy and fantastic looking tool called duf to display statistics on free disk space in Unix, Linux, macOS, *BSD, Android, and Windows written in Golang.

ADVERTISEMENTS

duf – Disk Usage/Free Utility for Linux, BSD, macOS & Windows

duf means Disk Usage/Free utility. It works on Linux and Unix-like systems, including Windows. It comes with the following features:

  • Easy to use
  • Colorful display
  • Adjust height and width as per your terminal resize movement
  • Sorting data as per our need
  • Filters and groups
  • JSON outputs and more

Installing duf

Make sure you have a working Go environment, including a Golang compiler installed for source code installation. Open the terminal app and then use the git command:

git clone https://github.com/muesli/duf.git
cd duf
go build

How to install duf on Debian/Ubuntu Linux (pre built packages)

Use the wget command or curl command to download file:

wget https://github.com/muesli/duf/releases/download/v0.5.0/checksums.txt
wget https://github.com/muesli/duf/releases/download/v0.5.0/duf_0.5.0_linux_amd64.deb
sha256sum --ignore-missing -c checksums.txt

Checksum confirmation:

duf_0.5.0_linux_amd64.deb: OK

Install .deb Packages on your Debian or Ubuntu box:
sudo apt install ./duf_0.5.0_linux_amd64.deb
Sample session:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'duf' instead of './duf_0.5.0_linux_amd64.deb'
The following NEW packages will be installed:
  duf
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/1031 kB of archives.
After this operation, 2486 kB of additional disk space will be used.
Get:1 /tmp/duf_0.5.0_linux_amd64.deb duf amd64 0.5.0 [1031 kB]
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package duf.
(Reading database ... 15411 files and directories currently installed.)
Preparing to unpack /tmp/duf_0.5.0_linux_amd64.deb ...
Unpacking duf (0.5.0) ...
Setting up duf (0.5.0) ...

Installing RPM file on CentOS/RHEL/Fedora/OpenSUSE Linux

Try the following command to install rpm file:

wget https://github.com/muesli/duf/releases/download/v0.5.0/duf_0.5.0_linux_amd64.rpm
wget https://github.com/muesli/duf/releases/download/v0.5.0/checksums.txt
sha256sum --ignore-missing -c checksums.txt
rpm -ivh duf_0.5.0_linux_amd64.rpm

Outputs:

Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:duf-0:0.5.0-1                    ################################# [100%]

Arch Linux install duf using AUR

Clone the repo and install it:

# get ready for AUR 
# sudo pacman -S --needed base-devel
git clone https://aur.archlinux.org/duf.git 
cd duf
less PKGBUILD
makepkg -si

Android user with termux

Run:
pkg install duf

macOS Unix install duf

Use the brew command:
brew install duf
OR use the port command sudo port selfupdate && sudo port install duf

FreeBSD install duf

Execute the pkg command sudo sh -c 'pkg update && pkg upgrade && pkg install duf'

MS-Windows install duf using scoop

Type at DOS/Windows prompt:
scoop install duf

How do I use duf?

All you have to do is type:
duf

Pretty? Right? We can force duf list specific devices and mount points:
duf /home
duf /
duf /dev/ /jails/ /rsnapshot

Let us display all file systems including pseudo, duplicate, inaccessible file systems:
duf --all

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 2 local devices                                                                                                    │
├──────────────────────────┬────────┬────────┬────────┬───────────────────────────────┬─────────┬────────────────────┤
│ MOUNTED ON               │   SIZE │   USED │  AVAIL │              USE%             │ TYPE    │ FILESYSTEM         │
├──────────────────────────┼────────┼────────┼────────┼───────────────────────────────┼─────────┼────────────────────┤
│ /                        │ 815.8G │ 271.9G │ 502.5G │ [######..............]  33.3% │ ext4    │ /dev/nixcraft/root │
│ /sys/fs/fuse/connections │     0B │     0B │     0B │                               │ fusectl │ fusectl            │
╰──────────────────────────┴────────┴────────┴────────┴───────────────────────────────┴─────────┴────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────╮
│ 8 fuse devices                                                                        │
├────────────────────────────────┬──────┬──────┬───────┬──────┬────────────┬────────────┤
│ MOUNTED ON                     │ SIZE │ USED │ AVAIL │ USE% │ TYPE       │ FILESYSTEM │
├────────────────────────────────┼──────┼──────┼───────┼──────┼────────────┼────────────┤
│ /proc/cpuinfo                  │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /proc/diskstats                │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /proc/loadavg                  │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /proc/meminfo                  │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /proc/stat                     │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /proc/swaps                    │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /proc/uptime                   │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
│ /sys/devices/system/cpu/online │   0B │   0B │    0B │      │ fuse.lxcfs │ lxcfs      │
╰────────────────────────────────┴──────┴──────┴───────┴──────┴────────────┴────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 40 special devices                                                                                                   │
├─────────────────────────────────┬────────┬──────┬────────┬───────────────────────────────┬─────────────┬─────────────┤
│ MOUNTED ON                      │   SIZE │ USED │  AVAIL │              USE%             │ TYPE        │ FILESYSTEM  │
├─────────────────────────────────┼────────┼──────┼────────┼───────────────────────────────┼─────────────┼─────────────┤
│ /dev                            │ 492.0K │ 4.0K │ 488.0K │ [....................]   0.8% │ tmpfs       │ none        │
│ /dev/.lxd-mounts                │ 100.0K │   0B │ 100.0K │                               │ tmpfs       │ tmpfs       │
│ /dev/console                    │     0B │   0B │     0B │                               │ devpts      │ devpts      │
│ /dev/full                       │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/fuse                       │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/lxd                        │ 100.0K │   0B │ 100.0K │                               │ tmpfs       │ tmpfs       │
│ /dev/mqueue                     │     0B │   0B │     0B │                               │ mqueue      │ mqueue      │
│ /dev/net/tun                    │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/null                       │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/ptmx                       │     0B │   0B │     0B │                               │ devpts      │ devpts      │
│ /dev/pts                        │     0B │   0B │     0B │                               │ devpts      │ devpts      │
│ /dev/random                     │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/shm                        │  15.5G │   0B │  15.5G │                               │ tmpfs       │ tmpfs       │
│ /dev/tty                        │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/urandom                    │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /dev/zero                       │  15.4G │   0B │  15.4G │                               │ devtmpfs    │ udev        │
│ /proc                           │     0B │   0B │     0B │                               │ proc        │ proc        │
│ /proc/sys/fs/binfmt_misc        │     0B │   0B │     0B │                               │ binfmt_misc │ binfmt_misc │
│ /proc/sys/kernel/random/boot_id │ 492.0K │ 4.0K │ 488.0K │ [....................]   0.8% │ tmpfs       │ none        │
│ /run                            │  15.5G │ 8.1M │  15.5G │ [....................]   0.1% │ tmpfs       │ tmpfs       │
│ /sys                            │     0B │   0B │     0B │                               │ sysfs       │ sysfs       │
│ /sys/firmware/efi/efivars       │     0B │   0B │     0B │                               │ efivarfs    │ efivarfs    │
│ /sys/fs/cgroup                  │  15.5G │   0B │  15.5G │                               │ 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     │ tracefs     │
╰─────────────────────────────────┴────────┴──────┴────────┴───────────────────────────────┴─────────────┴─────────────╯

Sorting the output

The syntax is:
duf --sort {keyword}
duf --sort size
duf --sort used

Valid keywords are: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, and filesystem.
We can also show or hide specific columns as follows:
duf --output {keyword}
duf --output mountpoint,size,usage

dark vs light theme

We can set color or themes. Possible values are:
duf -theme dark
duf --theme light

JSON output

Do you like to use duf output as JSON for external commands? Try:
duf --json

Summing up

Overall, duf is an excellent little command-line utility. Perfect for personal Linux desktop, macOS, or development server. However, I won’t install it on the production server. Do check the project home page. If you have any concerns or have other such CLI goodies, let me know in the comment section below.

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:

2 comments… add one
  • gobi Jan 16, 2021 @ 19:49

    > However, I won’t install it on the production server.
    why not? look nice to me. if you’re going to tell us to install duf, then you had better practice what you preach.

    • Rajiv Jan 17, 2021 @ 4:19

      You are an idiot. He already installed it in his system. We avoid installing unwanted stuff in production servers. It keeps server secure and less moving parts too.

Leave a ReplyCancel reply

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

Comment

Name *

Email *

Website

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @ [email protected]

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK