You can do that. Just be careful not to remove essential packages, like dpkg
and libc6
, else your system will end up being unusable. The following script, which depends on python3-apt
, should help:
#!/usr/bin/python3
import apt
cache = apt.cache.Cache()
for package in cache:
if (package.is_installed and
package.candidate.priority not in ("required", "important")):
print(package.name, end=" ")
print()