Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active March 2, 2022 06:49
Show Gist options
  • Save gmolveau/4f1ababb87f9698030fa578f8ae3672e to your computer and use it in GitHub Desktop.
Save gmolveau/4f1ababb87f9698030fa578f8ae3672e to your computer and use it in GitHub Desktop.
debian/ubuntu apt-get list installed top-level packages/apps only without dependencies
# source : https://unix.stackexchange.com/a/369653
# not a perfect solution but it helps
python3 -c "from apt import cache;manual = set(pkg for pkg in cache.Cache() if pkg.is_installed and not pkg.is_auto_installed);depends = set(dep_pkg.name for pkg in manual for dep in pkg.installed.get_dependencies('PreDepends', 'Depends', 'Recommends') for dep_pkg in dep);print('\n'.join(pkg.name for pkg in manual if pkg.name not in depends))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment