Forrest logo
back to the nix-collect-garbage tool

nix-collect-garbage:tldr:0bfbe

nix-collect-garbage: Simulate the deletion of old store paths.
$ sudo nix-collect-garbage --delete-old --dry-run
try on your machine

The command sudo nix-collect-garbage --delete-old --dry-run is used to collect and delete unnecessary or unused files from the Nix package manager's binary cache.

Here is what each part of the command does:

  • sudo: This command is used to execute the following command with administrative privileges. It allows the user to perform actions that require root or superuser access.

  • nix-collect-garbage: This is a Nix command that clears unneeded files from the binary cache.

  • --delete-old: This flag tells nix-collect-garbage to remove old entries from the binary cache. It deletes unused packages, generations, and other outdated files.

  • --dry-run: This flag is used for testing purposes and allows you to preview the changes that will be made without actually deleting anything. It shows a list of files that would be removed if the command were run without the --dry-run flag.

By running sudo nix-collect-garbage --delete-old --dry-run, you can see the list of files and packages that would be deleted if the command were executed without the --dry-run flag. It helps you understand the impact of the command and make sure you're not unintentionally removing important files.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the nix-collect-garbage tool