← All commands
Topic hub System & Storage
Windows Linux System & Storage System

Windows cleanmgr (Disk Cleanup) equivalent in Linux

Removes temporary files, old package caches, and other items that can safely be deleted to recover disk space.

Windows cleanmgr (Disk Cleanup)
Linux equivalents
Debian/Ubuntu apt
sudo apt clean && sudo apt autoremove
Fedora dnf
sudo dnf clean all && sudo dnf autoremove
Arch pacman
sudo pacman -Sc

Overview

What this command does

Removes temporary files, old package caches, and other items that can safely be deleted to recover disk space.

Migration tip: ncdu is useful for finding large directories before deleting anything. Install it with your distribution package manager, then run sudo ncdu /.

Practical tasks

Common use cases

Free up disk space

Removes temporary files, old package caches, and other items that can safely be deleted to recover disk space.

sudo apt clean && sudo apt autoremove

Debian/Ubuntu: clear downloaded packages and remove unused dependencies

sudo dnf clean all && sudo dnf autoremove

Fedora: clear cached metadata/packages and remove unused dependencies

sudo pacman -Sc

Arch: remove packages that are no longer installed from the package cache

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

sudo apt clean
sudo apt autoremove
sudo dnf clean all
sudo dnf autoremove
sudo pacman -Sc
sudo journalctl --vacuum-size=200M

Walkthrough

Examples with explanations

# Debian/Ubuntu package cache and unused dependencies:
sudo apt clean
sudo apt autoremove

# Fedora package cache and unused dependencies:
sudo dnf clean all
sudo dnf autoremove

# Arch package cache (review the prompt before confirming):
sudo pacman -Sc

# Any systemd-based distribution: limit journal size:
sudo journalctl --vacuum-size=200M

Reference

Common options and variations

Command or optionUse
sudo apt clean && sudo apt autoremoveDebian/Ubuntu: clear downloaded packages and remove unused dependencies
sudo dnf clean all && sudo dnf autoremoveFedora: clear cached metadata/packages and remove unused dependencies
sudo pacman -ScArch: remove packages that are no longer installed from the package cache
sudo journalctl --vacuum-size=200MAll three distributions: trim the systemd journal to approximately 200 MB
sudo ncdu /Interactively inspect disk usage before cleaning

Distro differences

Debian/Ubuntu vs Fedora vs Arch

Package-cache cleanup is distribution-specific, while systemd journal cleanup uses journalctl on Debian/Ubuntu, Fedora and Arch.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu apt sudo apt clean && sudo apt autoremove APT separates cache cleanup from removal of unused dependency packages.
Fedora dnf sudo dnf clean all && sudo dnf autoremove DNF can clear cached metadata/packages and remove dependencies no longer required.
Arch pacman sudo pacman -Sc Removes cached packages that are no longer installed; review the confirmation prompt.

Important

What to watch out for

Package-cache cleanup commands differ by distribution. Review the package manager prompt before confirming, and inspect disk usage before deleting unfamiliar files.

Keep learning

Related System & Storage commands