7 Essential duf Command Examples for Linux Disk Management

Checking disk space is a routine task for any Linux user. The standard df command works, but its output is plain and hard to scan. The duf command fixes that. It shows disk usage in a colorized table you can read at a glance. This article covers seven practical ways to use duf for faster, clearer disk monitoring.

1. Check All Mountpoints with the duf Command

Run duf with no arguments and it shows every mounted file system on your machine. The output is a clean table with columns for size, used space, available space, and usage percentage. Each row is color-coded. Green means plenty of room. Red means you are running low.

$ duf
╭─────────────────────────────────────────────────────────────────╮
│                         Local Mounts                            │
├────────────────┬──────┬────────┬────────┬───────┬───────────────┤
│ Mount          │ Size │ Used   │ Avail  │ Use%  │ Type          │
├────────────────┼──────┼────────┼────────┼───────┼───────────────┤
│ /              │ 98G  │ 45G    │ 53G    │ 45.9% │ ext4          │
│ /boot          │ 1.9G │ 152M   │ 1.7G   │ 8.1%  │ ext4          │
│ /home          │ 50G  │ 12G    │ 38G    │ 24.0% │ ext4          │
│ /var           │ 20G  │ 16G    │ 4.0G   │ 80.0% │ ext4          │
╰────────────────┴──────┴────────┴────────┴───────┴───────────────╯

The duf command groups mounts into sections. Local drives appear first. Network shares, FUSE mounts, and special file systems each get their own block. This beats the flat wall of text that df -h dumps on you. You can see at a glance which volumes are local and which are remote. I check this every morning on my servers to spot problems before they cause downtime.

2. Filter by File System Type Using the duf Command

Sometimes you only care about specific file systems. Maybe you want ext4 and xfs but not tmpfs or squashfs. The duf command makes this easy with the --only flag.

$ duf --only ext4,xfs

This hides everything except ext4 and xfs mounts. The output shrinks to just the data you need. You can also invert the filter with --exclude-type to skip file system types you do not want to see.

$ duf --exclude-type tmpfs,squashfs,devtmpfs

I use the exclude version more often. Most systems have a dozen tmpfs mounts that clutter up the screen. Skipping them gives you the real disk picture without the noise. When you combine duf filters with sorting, you get a focused view of just the storage that matters.

3. Sort Output with the duf Command

By default duf sorts mounts by mount point. That works, but it is not always what you need. You want to see which disks are filling up first. The --sort flag changes the order.

$ duf --sort avail

This sorts by available space, smallest first. Drives about to run out appear at the top. You can also sort by size, used, mountpoint, or type. I sort by available space on most days. It shows me the problem drives immediately without scrolling.

4. Exclude Specific Mount Points

Some mount points you never need to see. Snap packages create a lot of loop devices. Docker mounts stack up fast. The duf command lets you skip them with the --exclude flag. Duf handles these exclusions cleanly. The output stays readable and focused on what matters.

$ duf --exclude /snap,/var/lib/docker

You can pass multiple paths separated by commas. This keeps your output clean and focused. I have a shell alias for this specific setup.

alias duc='duf --exclude /snap,/var/lib/docker,/run --sort avail'

One command gives me the full disk picture with only the mounts I care about, sorted by free space. I run this constantly when I am diagnosing storage issues.

5. Display Output in JSON Format

Scripts and monitoring tools often need structured data. The duf command supports JSON output with the --json flag.

$ duf --json

The output is a JSON array of mount objects. Each one has the mount point, file system type, total size, used space, available space, and usage percentage. Pipe it into jq to extract exactly what you need. I wrote a cron script that checks disk usage and sends a push notification when any partition goes over 90%.

If you already know how to process JSON with jq, this is straightforward to automate.

6. Customize the duf Command Themes

Duf ships with built-in themes for its colored output. You can pick between dark and light modes, or create your own.

$ duf --theme dark

Built-in themes include dark and light. Custom themes live in ~/.config/duf/themes.yaml. You can copy the default file and tweak the hex color values to match your terminal. I made a custom theme with softer contrast colors. It is easier on my eyes during late-night work sessions.

This level of customization is one thing that sets the duf command apart from df. You can make it look exactly how you want. Duf was designed to be pleasant to read, not just functional.

7. Combine Options for Regular Monitoring

The real power comes from stacking options together. You can filter by type, exclude specific mounts, and sort by available space all in one command.

$ duf --only ext4,xfs --exclude /boot,/snap --sort avail

This shows only ext4 and xfs file systems. It skips boot and snap partitions. Results are sorted by free space ascending. I keep this exact invocation as a shell alias for my daily checks. Running it takes less than a second and gives me everything I need.

Disk monitoring does not need to be complicated. The duf command gives you a clear picture of your storage in seconds. It is available in most package managers. If you work with Linux servers daily, duf is one of those tools you appreciate the moment you try it. You can grab the latest release directly on GitHub or install it via Debian packages. On Ubuntu or Debian, run sudo apt install duf. On Arch, it is sudo pacman -S duf. Homebrew users can run brew install duf.

If you want to explore more modern Linux CLI replacements, check out our guides on fd for file searching and dust for disk usage analysis. Both are well worth adding to your toolkit.

Leave a Reply

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

Related Posts