3

After completely changing my sources.list, I'd like to only have packages which I can update, obviously. Does apt do this automatically? How can I find out?

How can I delete all packages at once which cannot be reached with my actual sources.list?

2

Identifying packages which are no longer available

The most useful tool to list packages which need to be checked in this situation, is apt-show-versions. Install that, then run it as follows:

  • apt-show-versions | grep "No available version in archive"

    to list all packages which aren’t available at all with your current repository configuration (and should be removed).

  • apt-show-versions | grep "newer than version in archive"

    to list all packages whose currently installed version is newer than the versions available with your current repository configuration (and which you might wish to downgrade).

You can obtain similar information using apt list --installed and looking for [installed,local], but that doesn’t distinguish between packages which aren’t available from your configured repositories and packages which are available, but in an older version than the currently installed one.

aptitude can show you this too; start it and look for the “Obsolete and Locally Created Packages” section in the TUI. That will contain all the packages which aren’t available from your configured repositories. You can list the packages using

aptitude search '~o'

in your shell too.

Deleting packages which are no longer available

aptitude provides the simplest answer to your actual question:

aptitude purge '~o'

will purge all “obsolete” packages (i.e. packages which are no longer available from the repositories).

Identifying and deleting contrib or non-free packages

aptitude can also identify contrib or non-free packages without needing to remove the corresponding repositories:

aptitude search '~i ~scontrib/.*' '~i ~snon-free/.*'

You can purge them directly:

aptitude purge '~i ~scontrib/.*' '~i ~snon-free/.*'
1

How to identify all non-free or contrib packages

You can identify contrib and non-free packages with vrms

sudo apt install vrms
vrms
  • Although if there are tailor-made packages for my problem, I prefer using the ones I already have. – Nepumuk Jul 24 '18 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.