Skip to main content
3 of 3
Trying with a debian package called deborphan.
Rafa Mori
  • 303
  • 1
  • 7

For Debian-Based distro:

There is a package called deborphan package, maybe fit. The man tells this at first lines:

DESCRIPTION

Deborphan finds packages that have no packages depending on them. The default operation is to search within the libs, oldlibs and introspection sections to hunt down unused libraries.

If it is invoked with an optional list of packages, only the dependencies on those packages will be checked. The results are printed to stdout as if the option --show-deps had been given. Searching for specific packages will show the package, regardless of its priority. It is possible to specify -, to read a list of packages from standard input.

Or you can try this (CHECK DIRECTORIES AND FILES BEFORE REMOVING!):

#!/usr/bin/env bash # List of common config directories. Put yours or some you know in this list, separating with spaces.. declare -a config_dirs=(~/.config ~/.local ~/.gnome) # Trying to find orphaned directories for dir in "${config_dirs[@]}"; do find "$dir" -type d -name ".*" | while read -r orphaned_dir; do if ! grep -q "$orphaned_dir" /var/lib/dpkg/info/status; then echo "Orphaned: $orphaned_dir" read -p "Want to remove this directory? [y/N] " yn if [[ $yn == [Yy] ]]; then rm -rf "${orphaned_dir}" fi fi done done 

Remember to validate before removing.

About "/var/lib/dpkg/info/status" file:

This file is used by dpkg and higher-level tools like apt to track the state of packages. It is crucial for the proper functioning of the package management system because it stores essential information about which packages are installed, their versions, dependencies, and more.

When you uninstall a package, the package is removed, but its configuration entries may remain, which is why the status file can still list packages that have been removed but whose configurations remain on the system.

For Arch-Based distros:

I think you can just do this and it will be enough:

sudo pacman -R $(pacman -Qdtq) 

Hope this helps!

Rafa Mori
  • 303
  • 1
  • 7