Convert Figma logo to code with AI

muesli logoduf

Disk Usage/Free Utility - a better 'df' alternative

12,655
395
12,655
75

Top Related Projects

Terminal disk space navigator 🔭

8,538

A more intuitive version of du in rust

3,790

Fast disk usage analyzer with console interface written in Go

Quick Overview

duf is a cross-platform disk usage/free utility written in Go. It provides a more detailed and user-friendly alternative to the standard df command, with support for various file systems and cloud storage providers.

Pros

  • Cross-platform: Supports Windows, macOS, and Linux, making it a versatile tool for users across different operating systems.
  • Detailed Information: Displays comprehensive disk usage statistics, including total size, used space, free space, and inode usage.
  • Cloud Storage Support: Integrates with popular cloud storage providers like Amazon S3, Google Cloud Storage, and Microsoft Azure Blob Storage.
  • Customizable Output: Allows users to customize the output format, including columns and sorting options, to suit their preferences.

Cons

  • Limited Functionality: While more feature-rich than df, duf may still lack some advanced functionality that power users might require.
  • Dependency on Go Runtime: Users need to have the Go runtime installed on their system to run duf, which may be a barrier for some.
  • Potential Performance Impact: Depending on the size and complexity of the file systems being analyzed, duf may have a noticeable performance impact compared to the standard df command.
  • Lack of Advanced Filtering: The tool's filtering capabilities may be limited compared to more specialized disk usage analysis tools.

Getting Started

To get started with duf, follow these steps:

  1. Install the Go programming language on your system if you haven't already.
  2. Download the latest release of duf from the GitHub repository: https://github.com/muesli/duf/releases
  3. Extract the downloaded archive and move the duf binary to a directory in your system's PATH.
  4. Open a terminal or command prompt and run the duf command to see the disk usage information for your system.

You can customize the output of duf by using various command-line flags, such as:

  • duf -h: Display the help menu with all available options.
  • duf -a: Show all file systems, including virtual and network-based ones.
  • duf -t ext4,xfs: Only show file systems of the specified types.
  • duf -s size,used,avail: Customize the columns to be displayed.
  • duf -sort used: Sort the output by used space.

For more advanced usage, you can refer to the project's README file, which provides detailed documentation and examples.

Competitor Comparisons

Terminal disk space navigator 🔭

Pros of diskonaut

  • Interactive visualization of disk space usage
  • Allows real-time deletion of files and directories
  • Provides a more detailed breakdown of space usage by file type

Cons of diskonaut

  • Limited to analyzing a single directory at a time
  • Requires more system resources due to its graphical interface
  • Less suitable for quick disk space checks across multiple filesystems

Code comparison

diskonaut:

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let args: Vec<String> = env::args().collect();
    let path = Path::new(&args[1]);
    let mut app = App::new(path)?;
    app.run()?;
    Ok(())
}

duf:

func main() {
    flags := parseFlags()
    if err := run(flags); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}

Both projects use a main function to initiate the application, but diskonaut focuses on parsing a single directory path, while duf is designed to handle multiple flags and filesystem checks.

8,538

A more intuitive version of du in rust

Pros of dust

  • More detailed file and directory size breakdown
  • Supports sorting and filtering options
  • Faster performance for large directory structures

Cons of dust

  • Less visually appealing output compared to duf's colorful interface
  • Lacks disk usage information for mounted filesystems
  • May require more command-line arguments for customization

Code Comparison

dust:

pub fn sort_entries(entries: &mut Vec<Dir>, sort_by: SortBy) {
    match sort_by {
        SortBy::Name => entries.sort_by(|a, b| a.name.cmp(&b.name)),
        SortBy::Size => entries.sort_by(|a, b| b.size.cmp(&a.size)),
    }
}

duf:

func printTable(w io.Writer, s *stats, opts *Options) {
    table := tablewriter.NewWriter(w)
    table.SetHeader([]string{"Mounted on", "Size", "Used", "Avail", "Use%", "Inodes", "IUsed", "IFree", "IUse%", "Type"})
    table.SetBorder(false)
    table.SetAutoWrapText(false)
    table.SetAutoFormatHeaders(true)
}

The code snippets show that dust focuses on sorting and organizing file entries, while duf emphasizes presenting disk usage information in a tabular format.

3,790

Fast disk usage analyzer with console interface written in Go

Pros of gdu

  • Faster performance, especially for large directories
  • Interactive mode with real-time updates
  • Supports multiple units (bytes, KB, MB, etc.)

Cons of gdu

  • Less colorful and visually appealing output
  • Fewer formatting options for display
  • Limited platform support compared to duf

Code Comparison

gdu:

func (a *App) analyzeDir(ctx context.Context, dir *Dir, parentDir *Dir) error {
    files, err := os.ReadDir(dir.Path)
    if err != nil {
        return err
    }
    // ... (additional code)
}

duf:

func (m *Mount) Usage() (*UsageStat, error) {
    stat := syscall.Statfs_t{}
    err := syscall.Statfs(m.Mountpoint, &stat)
    if err != nil {
        return nil, err
    }
    // ... (additional code)
}

Both gdu and duf are disk usage analysis tools written in Go. gdu focuses on speed and interactivity, making it ideal for analyzing large directories quickly. duf, on the other hand, provides a more visually appealing output with extensive formatting options and broader platform support. The code snippets show that gdu uses a directory analysis approach, while duf relies on system calls to gather disk usage information. Choose gdu for faster performance and interactivity, or duf for a more comprehensive and visually pleasing disk usage overview.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

duf

Latest Release Go Doc Software License Build Status Go ReportCard

Disk Usage/Free Utility (Linux, BSD, macOS & Windows)

duf

Features

  • User-friendly, colorful output
  • Adjusts to your terminal's theme & width
  • Sort the results according to your needs
  • Groups & filters devices
  • Can conveniently output JSON

Installation

Packages

Linux

  • Arch Linux: pacman -S duf
  • Ubuntu 22.04 / Debian unstable: apt install duf
  • Nix: nix-env -iA nixpkgs.duf
  • Void Linux: xbps-install -S duf
  • Gentoo Linux: emerge sys-fs/duf
  • Packages in Alpine, Debian & RPM formats

BSD

  • FreeBSD: pkg install duf
  • OpenBSD: pkg_add duf

macOS

  • with Homebrew: brew install duf
  • with MacPorts: sudo port selfupdate && sudo port install duf

Windows

Android

  • Android (via termux): pkg install duf

Binaries

  • Binaries for Linux, FreeBSD, OpenBSD, macOS, Windows

From source

Make sure you have a working Go environment (Go 1.17 or higher is required). See the install instructions.

Compiling duf is easy, simply run:

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

Usage

You can simply start duf without any command-line arguments:

duf

If you supply arguments, duf will only list specific devices & mount points:

duf /home /some/file

If you want to list everything (including pseudo, duplicate, inaccessible file systems):

duf --all

Filtering

You can show and hide specific tables:

duf --only local,network,fuse,special,loops,binds
duf --hide local,network,fuse,special,loops,binds

You can also show and hide specific filesystems:

duf --only-fs tmpfs,vfat
duf --hide-fs tmpfs,vfat

...or specific mount points:

duf --only-mp /,/home,/dev
duf --hide-mp /,/home,/dev

Wildcards inside quotes work:

duf --only-mp '/sys/*,/dev/*'

Display options

Sort the output:

duf --sort size

Valid keys are: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem.

Show or hide specific columns:

duf --output mountpoint,size,usage

Valid keys are: mountpoint, size, used, avail, usage, inodes, inodes_used, inodes_avail, inodes_usage, type, filesystem.

List inode information instead of block usage:

duf --inodes

If duf doesn't detect your terminal's colors correctly, you can set a theme:

duf --theme light

Color-coding & Thresholds

duf highlights the availability & usage columns in red, green, or yellow, depending on how much space is still available. You can set your own thresholds:

duf --avail-threshold="10G,1G"
duf --usage-threshold="0.5,0.9"

Bonus

If you prefer your output as JSON:

duf --json

Troubleshooting

Users of oh-my-zsh should be aware that it already defines an alias called duf, which you will have to remove in order to use duf:

unalias duf

Feedback

Got some feedback or suggestions? Please open an issue or drop me a note!