Disk usage analyzer with console interface written in Go

Related tags

Command Line gdu
Overview

go DiskUsage()

Build Status codecov Go Report Card Maintainability CodeScene Code Health

Pretty fast disk usage analyzer written in Go.

Gdu is intended primarily for SSD disks where it can fully utilize parallel processing. However HDDs work as well, but the performance gain is not so huge.

asciicast

Packaging status

Installation

Head for the releases and download binary for your system.

Using curl:

curl -L https://github.com/dundee/gdu/releases/latest/download/gdu_linux_amd64.tgz | tar xz
chmod +x gdu_linux_amd64
mv gdu_linux_amd64 /usr/bin/gdu

Arch Linux:

yay -S gdu

Debian:

dpkg -i gdu_*_amd64.deb

Ubuntu

add-apt-repository ppa:daniel-milde/gdu
apt-get update
apt-get install gdu

NixOS:

nix-env -iA nixos.gdu

Homebrew:

brew install -f gdu
brew link --overwrite gdu  # if you have coreutils installed as well

Snap:

snap install gdu-disk-usage-analyzer
snap connect gdu-disk-usage-analyzer:mount-observe :mount-observe
snap connect gdu-disk-usage-analyzer:system-backup :system-backup
snap alias gdu-disk-usage-analyzer.gdu gdu

Binenv

binenv install gdu

Go:

go get -u github.com/dundee/gdu/v4/cmd/gdu

Usage

  gdu [flags] [directory_to_scan]

Flags:
  -h, --help                          help for gdu
  -i, --ignore-dirs strings           Absolute paths to ignore (separated by comma) (default [/proc,/dev,/sys,/run])
  -I, --ignore-dirs-pattern strings   Absolute path patterns to ignore (separated by comma)
  -l, --log-file string               Path to a logfile (default "/dev/null")
  -m, --max-cores int                 Set max cores that GDU will use. 8 cores available (default 8)
  -c, --no-color                      Do not use colorized output
  -x, --no-cross                      Do not cross filesystem boundaries
  -H, --no-hidden                     Ignore hidden directories (beggining with dot)
  -p, --no-progress                   Do not show progress in non-interactive mode
  -n, --non-interactive               Do not run in interactive mode
  -a, --show-apparent-size            Show apparent size
  -d, --show-disks                    Show all mounted disks
  -v, --version                       Print version

Examples

gdu                                   # analyze current dir
gdu -a                                # show apparent size instead of disk usage
gdu              # analyze given dir
gdu -d                                # show all mounted disks
gdu -l ./gdu.log            # write errors to log file
gdu -i /sys,/proc /                   # ignore some paths
gdu -I '.*[abc]+'                     # ignore paths by regular pattern
gdu -c /                              # use only white/gray/black colors

gdu -n /                              # only print stats, do not start interactive mode
gdu -np /                             # do not show progress, useful when using its output in a script
gdu / > file                          # write stats to file, do not start interactive mode

Gdu has two modes: interactive (default) and non-interactive.

Non-interactive mode is started automtically when TTY is not detected (using go-isatty), for example if the output is being piped to a file, or it can be started explicitly by using a flag.

Hard links are counted only once.

File flags

Files and directories may be prefixed by a one-character flag with following meaning:

  • ! An error occurred while reading this directory.

  • . An error occurred while reading a subdirectory, size may be not correct.

  • @ File is symlink or socket.

  • H Same file was already counted (hard link).

  • e Directory is empty.

Running tests

make test

Benchmarks

Benchmarks performed on 50G directory (100k directories, 400k files) on 500 GB SSD using hyperfine. See benchmark target in Makefile for more info.

Cold cache

Filesystem cache was cleared using sync; echo 3 | sudo tee /proc/sys/vm/drop_caches.

Command Mean [s] Min [s] Max [s] Relative
gdu -npc ~ 3.714 ± 0.036 3.685 3.809 1.00
dua ~ 4.703 ± 0.011 4.691 4.721 1.27 ± 0.01
duc index ~ 20.776 ± 0.093 20.591 20.924 5.59 ± 0.06
ncdu -0 -o /dev/null ~ 20.933 ± 0.113 20.757 21.073 5.64 ± 0.06
diskus ~ 3.747 ± 0.027 3.707 3.779 1.01 ± 0.01
du -hs ~ 20.096 ± 0.128 19.916 20.313 5.41 ± 0.06
dust -d0 ~ 16.281 ± 0.118 16.148 16.490 4.38 ± 0.05

Warm cache

Command Mean [ms] Min [ms] Max [ms] Relative
gdu -npc ~ 643.5 ± 11.3 623.8 659.9 1.99 ± 0.12
dua ~ 389.7 ± 13.0 374.2 410.4 1.20 ± 0.08
duc index ~ 1241.1 ± 19.6 1205.4 1274.9 3.84 ± 0.23
ncdu -0 -o /dev/null ~ 1846.7 ± 11.9 1823.0 1859.9 5.71 ± 0.33
diskus ~ 323.4 ± 18.8 302.1 362.2 1.00
du -hs ~ 1027.7 ± 9.7 1009.0 1037.5 3.18 ± 0.19
dust -d0 ~ 8864.4 ± 35.9 8798.8 8906.6 27.41 ± 1.60

Alternatives

  • ncdu - NCurses based tool written in pure C
  • godu - Analyzer with carousel like user interface
  • dua - Tool written in Rust with interface similar to gdu (and ncdu)
  • diskus - Very simple but very fast tool written in Rust
  • duc - Collection of tools with many possibilities for inspecting and visualising disk usage
  • dust - Tool written in Rust showing tree like structures of disk usage
Comments
  • enormous memory consumption

    enormous memory consumption

    
    ┌────────────────────────────────────────────────────────────────────────────────────────────── Scanning... ───────────────────────────────────────────────────────────────────────────────────────────────┐     
        │                                                                                                                                                                                                          │     
        │                                                                                                                                                                                                          │     
        │  Total items: 105,268,925 size: 23.9 TiB                                                                                                                                
        
    
    PID     TID  MINFLT MAJFLT  VSTEXT VSLIBS   VDATA VSTACK  LOCKSZ  VSIZE   RSIZE  PSIZE   VGROW  RGROW  SWAPSZ RUID      EUID      MEM  CMD        1/1
    2665192       -   93847    264   2420K  1496K  130.6G   132K      0K 139.4G  119.1G     0K  335.0M 370.7M    9.5G root      root      47%  gdu
    
    

    119gb of ram per 105m of files

    opened by sss123next 25
  • -x does not seem to honor filesystem boundaries - 5.10.0

    -x does not seem to honor filesystem boundaries - 5.10.0

    I have the following config

    ┌──┬─────┬──────────────┬────┬────┬─────┬─────────┬─────┬──────┬──────────────────┐
    │id│ dev │  filesystem  │disk│type│used │  use%   │ free│ size │mount point       │
    ├──┼─────┼──────────────┼────┼────┼─────┼─────────┼─────┼──────┼──────────────────┤
    │44│259:5│/dev/nvme3n1  │SSD │xfs │118Mi│ 1%      │ 11Gi│11Gi  │/var/app-local    │
    │55│259:2│/dev/nvme5n1  │SSD │xfs │100Mi│ 1%      │9.9Gi│10.0Gi│/var/app          │
    │38│259:7│/dev/nvme0n1p1│SSD │xfs │7.5Gi│75% ███▊ │2.5Gi│10.0Gi│/                 │
    │42│259:4│/dev/nvme4n1  │SSD │xfs │3.1Gi│35% █▊   │5.9Gi│9.0Gi │/usr/local/app    │
    │54│259:1│/dev/nvme2n1  │SSD │xfs │568Mi│19% ▉    │2.4Gi│3.0Gi │/var/log          │
    │43│259:3│/dev/nvme6n1  │SSD │xfs │614Mi│30% █▌   │1.4Gi│2.0Gi │/tmp              │
    │57│259:3│/dev/nvme6n1  │SSD │xfs │614Mi│30% █▌   │1.4Gi│2.0Gi │/var/tmp          │
    └──┴─────┴──────────────┴────┴────┴─────┴─────────┴─────┴──────┴──────────────────
    

    when I run gdu from / I do not expect to see gdu counting totals for /var/app-local but that is what happens. Here is output from ncdu and gdu. The sizes differ as -x does not seem to work for gdu. gdu -x image

    ncdu -x image

    bug 
    opened by daniejstriata 20
  • arm64 architecture is missing for snap install

    arm64 architecture is missing for snap install

    On a rasp pi 4 with arm64 architecture it is not possible to install gdu because only armhf builds are provided. Please provide arm64 builds as well :-)

    Thank you very much in advance!

    bug 
    opened by chrbayer 16
  • gdu version of `go get` is very simple

    gdu version of `go get` is very simple

    Just like this post https://github.com/dundee/gdu/issues/31#issuecomment-779896277

    Now I tried to update my gdu to the latest commit, so I use go get -u github.com/dundee/gdu again, but the gdu in my PATH which is ~/.go/bin/gdu is very simple as above link has listed and

    >> gdu -v
    Version:         development
    >> gdu -h
    Usage of gdu:
      -ignore string
            Absolute paths to ignore (separated by comma) (default "/proc,/dev,/sys,/run")
      -log-file string
            Path to a logfile (default "/dev/null")
      -v    Prints version
    

    I tried to delete all gdu file and directories in my ~/.go which is my GOPATH and go get -u xxx again, or redefine my GOPATH to another directory like ~/go and go get -u xxx again, but all the gdu are the same simple one.

    So is this go get or the code itself wrong?

    bug 
    opened by c02y 14
  • Keep gdu open when spawning shell

    Keep gdu open when spawning shell

    I use the new 'b' shortcut to quickly open a shell on a folder that is of interest to me and it's very useful. One thing I think could be improved is if the shell would be opened without killing gdu, so that after exiting the shell I would still have all the data loaded, the same folder selected, etc. in order to investigate the next problematic folder and so on. Much like the way you can user "! ..." in vi to spawn a shell and resume where you were once the shell ends.

    bug 
    opened by Tungstwenty 10
  • Close item info modal when `i` is pressed again

    Close item info modal when `i` is pressed again

    When file info modal is shown, another pressing of i shortcut should close this modal.

    Details

    It should be checked in https://github.com/dundee/gdu/blob/master/tui/keys.go#L81 whether the page "info" is already shown. If so, the page should be removed and focus returned to main page same way as in https://github.com/dundee/gdu/blob/master/tui/keys.go#L27

    enhancement good first issue Hacktoberfest 
    opened by dundee 9
  • Export with FullNames

    Export with FullNames

    Hi,

    When exporting to JSON, there is no option to exprot using the full path. Rather the export only contains relevant paths. I can't see any option to export using full paths.

    Is there?

    opened by SonamorN 8
  • brew install fails when coreutils is already installed

    brew install fails when coreutils is already installed

    On my macOS system that has the coreutils formula already installed:

    $  brew install gdu
    ==> Downloading https://ghcr.io/v2/homebrew/core/gdu/manifests/4.10.0
    ######################################################################## 100.0%
    ==> Downloading https://ghcr.io/v2/homebrew/core/gdu/blobs/sha256:9af37b330b0d64a2cc96927f4bd9b005a2c492f8bd084c0a1df531e7b1f003c2
    ==> Downloading from https://pkg-containers-az.githubusercontent.com/ghcr1/blobs/sha256:9af37b330b0d64a2cc96927f4bd9b005a2c492f8bd084c0a1df531e7b1f003c2?se=2021-04-08T22%3A45%3A00Z&sig=pmNS716JpYgRzbYu9TTTG9o9f94Nx
    ######################################################################## 100.0%
    Error: Cannot install gdu because conflicting formulae are installed.
      coreutils: because both install `gdu` binaries
    
    Please `brew unlink coreutils` before continuing.
    
    Unlinking removes a formula's symlinks from /usr/local. You can
    link the formula again after the install finishes. You can --force this
    install, but the build may fail or cause obscure side effects in the
    resulting software.
    

    In coreutils, they link du to gdu to indicate that it's "GNU du". Personally I'm OK with unlinking coreutils, but this could be surprising to many users.

    One suggestion could be to provide a non-conflicting binary as an option (like go-gdu or something?)... Not sure what the best fix is.

    And, maybe there's no fix possible - but I just wanted to provide some new-user feedback 😉

    opened by hairyhenderson 7
  • Doesn't read external config file (again)

    Doesn't read external config file (again)

    gdu v5.18.0

    I enter the path to any file, even those that don't exist - it still reads the default config and shows no errors...

    [elem] ~ ❯ gdu --config-file /home/elem/.config/gdu/gdu.yaml 
    [elem] ~ ❯ gdu --config-file example
    [elem] ~ ❯ gdu --config-file example/example
    [elem] ~ ❯ gdu --config-file ~/example/example/example/example/abcdf
    [elem] ~ ❯ gdu --config-file
    Error: flag needs an argument: --config-file
    [elem] ~ ❯ 
    

    update If I run gdu --config-file /home/elem/.config/gdu/gdu.yaml then it simply erases my settings in this file and sets its defaults

    opened by Ved-un 6
  • [bug] cannot enter interaction mode in mintty

    [bug] cannot enter interaction mode in mintty

    In conhost (the default terminal emulator for windows), gdu can work. However, in mintty (the default terminal emulator for cygwin/msys2), gdu will behave like gdu -n.

    Thanks.

    opened by Freed-Wu 6
  • The directory calculation menu freezes

    The directory calculation menu freezes

    This happens if you hold down the r key to recalculate the current directory. The calculation menu freezes and does not update, only the q key works to exit the gdu. There is no such problem in ncdu, but the interface is not beautiful and the calculation speed is much slower than that of gdu, so I would like to fix this problem.

    My Neofetch:

                       -`                    [email protected] 
                      .o+`                   ---------------- 
                     `ooo/                   OS: Arch Linux x86_64 
                    `+oooo:                  Host: Inspiron N5110 
                   `+oooooo:                 Kernel: 5.16.2-zen1-1-zen 
                   -+oooooo+:                Uptime: 16 mins 
                 `/:-:++oooo+:               Packages: 1631 (pacman) 
                `/++++/+++++++:              Shell: fish 3.3.1 
               `/++++++++++++++:             Resolution: 1366x768 
              `/+++ooooooooooooo/`           DE: Plasma 5.23.5 
             ./ooosssso++osssssso+`          WM: KWin 
            .oossssso-````/ossssss+`         Theme: Breeze Light [Plasma], Breeze [GTK2/3] 
           -osssssso.      :ssssssso.        Icons: breeze-dark [Plasma], breeze-dark [GTK2/3] 
          :osssssss/        osssso+++.       Terminal: konsole 
         /ossssssss/        +ssssooo/-       Terminal Font: Hack 10 
       `/ossssso+/:-        -:/+osssso+-     CPU: Intel i7-2670QM (8) @ 3.100GHz 
      `+sso+:-`                 `.-/+oso:    GPU: NVIDIA GeForce GT 525M 
     `++:.                           `-/+/   GPU: Intel 2nd Generation Core Processor Family 
     .`                                 `/   Memory: 2304MiB / 7853MiB 
    
    
    opened by BlitDev 6
  • [bug] Screen flicker

    [bug] Screen flicker

    When it scans it flickers, and after that, any time I move the cursor (with arrow keys or mouse) it flickers.

    I use Windows Terminal, Windows 11 21H2/22H2, nothing else fancy, I don’t think (feel free to ask). No other CLI app does that. Flicker tested on two machines.

    Don’t flicker in WSL or VirtualBox Linux.

    bug 
    opened by onsamyj 3
  • Consecutive mouse clicks may be mistaken as double clicks

    Consecutive mouse clicks may be mistaken as double clicks

    First of all, thanks for working on mouse support! It works great. One edge case though: if I click an item and then click elsewhere quickly, it would be considered a double click:

    https://user-images.githubusercontent.com/44045911/189170109-09990763-f734-42eb-865e-fe9a56c31525.mov

    If this is a limitation/bug in tview, I would be willing to open an issue there instead.

    opened by kidonng 1
  • "Show apparent size" needed for WSL instance to Windows drive

    Hi,

    I'm not sure why this is happening but when I run gdu -dn I get the following output:

      Device      Size      Used      Free Used% Mount point
    /dev/sdc 251.0 GiB  13.7 GiB 237.3 GiB    5% /
    

    when I am inside a mnt to the Windows drive from my WSL the following happens: /mnt/d/Data/repo/security

    $ gdu -n
        7.8 EiB /packages
        4.8 EiB /app1
      -463550477559806976 B /app2
      -3473665266239336448 B /audit_configs
      -3801883870989672960 B /server-fixes
    

    to get the proper output I need to run it like this:

    $ gdu -na
      106.9 MiB /packages
        1.0 GiB /app1
      333.1 KiB /app2
      215.4 KiB /audit_configs
      442.2 MiB /server-fixes
    

    Is this expected behaviour? I'm not sure why the mnt is confusing the space from within WSL.

    opened by daniejstriata 1
  • Allow stopping scanning while preserving results

    Allow stopping scanning while preserving results

    Currently, gdu has an initial "scan" phase where it scans the disk and then once the scanning is complete, it allows results to be viewed. Stopping the scanning at any time, quits the app.

    Instead of quitting, do you think it would make sense to stop scanning and showing whatever has been scanned till now?

    This would help in cases where scanning is taking too much time, like a 60 TeraByte NFS disk!

    I had to stop GDU which had already scanned 300,000,000 items totalling about 14 TB because it was taking 80GB of RAM & 8 cores on the server. The cores were expected, but the excessive memory usage was not.

    If GDU could've just stopped the scanning, I would have still made sense of whatever it had scanned.

    I'm back to using ncdu now which is going at a snails pace, but atleast it will finish in a day or two without completely borking the system :(

    opened by dufferzafar 3
  • Feature: Add automatic rescan

    Feature: Add automatic rescan

    Sometimes you want to move the gdu terminal window to the right side of the screen (e.g via tmux), and execute another command on the left side, while monitoring the size changes. So it would be nice if, e.g, the "R" key (not "r") would start automatically scanning the folder, and when pressed again it would end.

    enhancement 
    opened by BlitDev 2
Releases(v5.20.0)
Owner
Daniel Milde
Daniel Milde
depstat is a dependency analyzer for Go modules enabled projects.

depstat is a dependency analyzer for Go modules enabled projects. It runs as part of the Kubernetes CI pipeline to help evaluate dependency updates to Kubernetes.

Kubernetes SIGs 31 Nov 1, 2022
mass-binding-target is a command line tool for generating binding target list by search plot files from disk.

mass-binding-target mass-binding-target is a command line tool for generating binding target list by search plot files from disk. Build Go 1.13 or new

null 0 Nov 5, 2021
donLoader is a shellcode loader creation tool that uses donut to convert executable payloads into shellcode to evade detection on disk.

donLoader WARNING: This is WIP, barely anything was tested properly. Use at your own risk. Description donLoader is a shellcode loader creation tool t

blink3n 14 Sep 20, 2022
Dependency-free replacement for GNU parallel, perfect fit for usage in an initramfs.

coshell v0.2.5 A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage. Licensed under GNU/GPL v2. How it works An sh -c

gdm85 41 May 11, 2022
Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically

Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically. The name is inspired by "Disk Inventory X" tool doing similar analysis for disk usage.

Aleks Obukhov 196 Nov 21, 2022
A cli that shows a GitHub-like language usage statistics bar.

barley A cli that shows a GitHub-like language usage statistics bar. barley analyses the programming languages used in a directory and creates a used

Barış İnandıoğlu 3 Jan 8, 2022
Basic usage of Vecty framework examples.

vecty-examples Basic usage of Vecty framework examples. Instructions Change directory to the folder with the example you wish to run Run wasmserve. To

Patricio Whittingslow 1 Jun 20, 2022
Console-based JVM monitoring tool

jvm-mon Console based JVM monitoring - when you just want to SSH into a server and see what's going on. jvm-top lets you monitor your JVM server appli

Andrejs Jermakovics 1.4k Nov 17, 2022
Console progress bar for Golang

Terminal progress bar for Go Installation go get github.com/cheggaaa/pb/v3 Documentation for v1 bar available here Quick start package main import (

Sergey Cherepanov 3.3k Nov 22, 2022
Utilities to prettify console output of tables, lists, progress-bars, text, etc.

go-pretty Utilities to prettify console output of tables, lists, progress-bars, text, etc. Table Pretty-print tables into ASCII/Unicode strings.

Naveen Mahalingam 1.6k Nov 27, 2022
oc CLI plugin to interact with Helm features provided by the OpenShift Console

OpenShift provides support for managing the lifecycle of Helm charts. This capability is limited primarily to the Web Console. This plugin enables the management of Helm charts similar to using the standalone Helm CLI while offloading much of the work to OpenShift.

Andrew Block 0 Aug 20, 2022
Simple console formatting library for Go

flair Simple console formatting library for Go Motivation There are definitely a bunch of other libraries like this, but I wanted one I knew would be

Beatrice T. Meyers 3 Aug 30, 2021
This is a Go Cli app that receives an string path to a log file, and based on it generates and prints in console an encoded polyline with the locations found in the log file.

GEOENCODE GO CLI APP DESCRIPTION This is a Go Cli app that receives an string path to a log file, and based on it generates and prints in console an e

Jose Luis Ojeda 1 Oct 1, 2021
Use Golang to achieve better console backend services

Use Golang to achieve better console backend services

null 1 Dec 7, 2021
Basic timestamped console printing.

loglines Basic timestamped console printing. What This is a very simple package with three functions: NowString() returns a string with the current ti

Grimdork.net 1 Nov 20, 2021
This is a cli to watch anime using the console/terminal.

monas-chinas-cli Este un un cli para ver anime usando la consola/terminal. This is a cli to watch anime using the console/terminal. ⚠️ AVISO ⚠️ Los an

FlamesX128 7 Jun 4, 2022
Windows API to hide console window by golang

Doge-Hide windows API to hide console window by golang ShowWindow ShowWindowAsy

TimWhite 14 Nov 7, 2022
mlp is a comman line tool responsible for creating, updating and deleting kubernetes resources based on files generated by Mia-Platform Console.

mlp is a comman line tool responsible for creating, updating and deleting kubernetes resources based on files generated by Mia-Platform Console.

Mia-Platform 5 Apr 28, 2022
Godbolt console wrapper for easily execute local file without any security risk and compiler.

Godbolt CLI Godbolt console wrapper for easily execute local file without any security risk and compiler. Install Compile the source code and add to y

aiocat 1 May 22, 2022