9

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?

Mouse.The.Lucky.Dog
  • 2,027
  • 2
  • 26
  • 37

3 Answers3

13

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.

Lesmana
  • 26,889
  • 20
  • 81
  • 86
scai
  • 10,543
  • 2
  • 25
  • 42
  • Why [`apt list`](https://manpages.debian.org/testing/apt/apt-patterns.7.en.html)/`aptitude search` `'?essential'`/`~E` include `apt` but `dpkg-query` alternative doesn't? [Isn't dpkg-query](https://www.debian.org/doc/manuals/aptitude/ch02s04.en.html) the correct output? – Pablo A May 11 '22 at 05:50
5
aptitude search ~E

for other search patterns you can look in aptitude doc.

rush
  • 27,055
  • 7
  • 87
  • 112
1
  • 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.

youfu
  • 241
  • 1
  • 8