Skip to content

Instantly share code, notes, and snippets.

@kleini
Last active June 4, 2019 08:08
Show Gist options
  • Save kleini/fed2d4ec203c9cf94169e2a30e60e53e to your computer and use it in GitHub Desktop.
Save kleini/fed2d4ec203c9cf94169e2a30e60e53e to your computer and use it in GitHub Desktop.
Find Debian/Ubuntu packages without installed dependencies
First of all we list packages during upgrade, that are not marked as automatically handled:
aptitude search -F '%p' --disable-columns '~U' | while read PACKAGE; do sudo apt-mark showmanual $PACKAGE; done
Second I want to find even those packages, that are already automatically handled but are still installed although nothing
installed depends on it
aptitude search -F '%p' --disable-columns '~U' | while read PACKAGE; do echo -n "$PACKAGE "; apt-cache rdepends $PACKAGE | tail +3 | while read RDEPEND; do dpkg --get-selections | egrep "^${RDEPEND}.*\s" | wc -l; done | paste -sd+ | bc; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment