While as Scott Goodgame says apt-get purge
can only purge packages that are installed, dpkg -P
does not have this limitation. So there's no need to reinstall a package for the purpose of re-uninstalling it with the purge
action.
Those skeptical that dpkg
has this ability can test it out, perhaps by installing, removing, and dpkg -P
-purging a package rarely present on desktop systems, with configuration files but minimal dependencies, such as gamin
.
To remove the packages' systemwide configuration files (this will also uninstall the packages if they're still installed, this acting like sudo apt-get purge ...
in that case), run:
sudo dpkg -P xserver-xorg `dpkg-query -f '${binary:Package} ' -W xfonts\*` gnome gdm
apt-get
matches regular expressions like xfonts*
, but dpkg
doesn't, which is the reason for the italicized backticked expression.
As a secondary matter, you might be surprised to learn apt-get
interprets xfonts*
as a regexp. If xfonts*
were expanded with shell-like expansion, it would match all names starting with xfonts
. Since it's expanded as a regexp instead, it matches all names with xfont
(not xfonts
, xfont
) anywhere in them, including packages like fonts-ipaexfont-gothic
. This is because, in regular expressions, x*
means "zero or more x
es." The pattern you probably want is ^xfonts
, which matches xfonts
at the beginning of a package name (or of a line, in the general use case).