free disk space

Find what fills a disk, then clear what is safe to clear: old package files, logs, caches.

  • disks
  • files
  • system

danger Steps marked in red delete, overwrite or stop something. Read each one before you run it.

Steps

  1. df -h

    see how full each disk is, and which one is short of space

  2. du -xh -d 1 / 2>/dev/null | sort -h

    the biggest folders at the top of that disk, biggest last

  3. ncdu -x /

    walk through the folders by size and delete from there, if ncdu is installed

  4. sudo journalctl --vacuum-size=200M

    shrink the system's logs to 200 MB

  5. sudo apt clean

    remove the downloaded package files (Debian, Ubuntu)

  6. sudo apt autoremove

    remove the packages nothing needs any more (Debian, Ubuntu)

  7. rm -rf ~/.cache/thumbnails

    danger delete the cached thumbnails, made again when needed

Notes

  • Fedora and RHEL: sudo dnf clean all and sudo dnf autoremove. Arch: sudo pacman -Sc.
  • -x keeps du and ncdu on that one disk, so other disks and network folders are not counted.
  • macOS: the same df -h and du -xh -d 1 /; Homebrew's downloads go with brew cleanup.

Commands used

  • df
  • du
  • ncdu
  • journalctl

Each has a page in lore: lore df opens it.