-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux Package Cleaning
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to cleaning packages on Linux, covering Arch Linux, CachyOS, and other distributions including cache cleaning, orphan removal, and package maintenance.
Clean package cache:
# Check cache size
du -sh /var/cache/pacman/pkg
# Remove old packages
sudo pacman -Sc
# Remove all cached packages
sudo pacman -SccWhat these commands do:
-
-Sc: Remove packages not installed -
-Scc: Remove all cached packages
Setup auto-clean:
# Create hook
sudo vim /etc/pacman.d/hooks/clean-cache.hookAdd:
[Trigger]
Operation = Upgrade
Type = Package
Target = *
[Action]
Description = Cleaning package cache...
When = PostTransaction
Exec = /usr/bin/pacman -Sc --noconfirmList orphans:
# List orphan packages
pacman -Qdt
# List with details
pacman -QdttRemove orphans:
# Remove orphans
sudo pacman -Rns $(pacman -Qdtq)
# Interactive removal
pacman -Rns $(pacman -Qdtq)List unused:
# List explicitly installed
pacman -Qe
# List unused dependencies
pacman -QdtCheck packages:
# Check for broken packages
pacman -Qkk
# Check dependencies
pacman -DkFull cleanup:
# Clean cache
sudo pacman -Sc
# Remove orphans
sudo pacman -Rns $(pacman -Qdtq)
# Check for issues
pacman -QkkClean cache:
# Check size
du -sh /var/cache/pacman/pkg
# Clean
sudo pacman -ScForce removal:
# Remove with force
sudo pacman -Rns $(pacman -Qdtq) --noconfirmThis guide covered package cleaning for Arch Linux, CachyOS, and other distributions, including cache cleaning, orphan removal, and maintenance.
- Package Management - Package management
- System Maintenance - System maintenance
- ArchWiki Package Cleaning: https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Cleaning_the_package_cache
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.