Pacman clean unused packages
Package managers can detect which packages were manually installed (at user or script explicit request) and which were implicitly installed as a prerequisite. When uninstalling the manually installed package, the prerequisite packages are often not auto-uninstalled. To recover the possibly significant amount of disk space (gigabytes perhaps) from these now unused packages, an autoremove command is useful.
Pacman is used in numerous Linux distros and in MSYS2. Show the auto-installed prerequisites:
This can be piped into the Pacman remove command upon verifying the packages above are indeed OK to remove:
pacman -Qdtq | pacman -Rs -
The package cache can contain gigabytes no longer needed. The pacman cache is cleared by:
For systems using “apt” the equivalent commands are:
apt autoremove apt autoclean