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.
cleanmgr (Disk Cleanup)
sudo apt clean && sudo apt autoremove
sudo dnf clean all && sudo dnf autoremove
sudo pacman -Sc
Overview
What this command does
On Windows, "cleanmgr (Disk Cleanup)" is used to free up disk space. On Linux, the closest practical mapping shown here is "sudo journalctl --vacuum-size=200M". Removes temporary files, old package caches, and other items that can safely be deleted to recover disk space. This reference is grouped under System & Storage → System.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows cleanmgr (Disk Cleanup) maps to package cache cleanup / journalctl vacuum for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Distribution details matter
The Debian/Ubuntu, Fedora and Arch rows are not identical. Use the row for your distribution instead of changing only the package-manager name in an example.
Elevated privilege appears in this workflow
At least one example uses sudo. Confirm the target path, device, service or package before running the elevated form; do not add sudo simply to bypass an unexplained permission error.
Command-specific caution
Package-cache cleanup commands differ by distribution. Review the package manager prompt before confirming, and inspect disk usage before deleting unfamiliar files.
For the broader concept behind this mapping, read Linux disks, storage and mounts.
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 option | Use |
|---|---|
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 |
sudo journalctl --vacuum-size=200M | All 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
The equivalent is distribution-specific for this task: Debian/Ubuntu uses "sudo apt clean && sudo apt autoremove"; Fedora uses "sudo dnf clean all && sudo dnf autoremove"; Arch uses "sudo pacman -Sc".
| Distribution | Package manager / base | Equivalent command | Difference 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
Keep learning