5

When I run synaptic, there are certain packages which synaptic treats as "essential". For example, if I select bash for removal, I will be warned that bash is an "essential package". If I then press the apply button I get a list of packages that are going to be acted on. One of those lists is the list of essential packages that I am about to remove.

Using the apt toolset, how can I vgenerate a list of all the packages that synaptic considers essential?

9

You can list all essential packages using aptitude search '?essential' or dpkg-query -Wf '${Package;-40}${Essential}\n' | grep yes.

Additionally there are also several packages with priority required that you shouldn't remove, too: dpkg-query -Wf '${Package;-40}${Priority}\n' | grep -E "required"

For your information, Essential and Priority are fields in the control file of a package.

4
aptitude search ~E

for other search patterns you can look in aptitude doc.

0
  • for daily use: apt list ?essential or apt list ~E
  • for script: apt-cache show ~E | grep -Po '(?<=^Package: ).*'

?essential and ~E are documented in apt-patterns(7), available on Ubuntu 20.04 LTS and Debian 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.