There are two kinds of removal: one keeps the settings, the other removes everything.
sudo dpkg -r (or sudo apt remove) deletes the package files and keeps its conffile. The database record stays: dpkg -s says Status: deinstall ok config-files, and dpkg -l shows rc. Install the package again and it picks up the saved setting.
sudo dpkg -P (or sudo apt purge) deletes the conffile and the record too: afterwards dpkg -s says nothing is known about the package. Even purge leaves alone the data the program wrote itself and the files in home directories.
dpkg refuses to remove a package another installed package depends on and prints dependency problems prevent removal: otherwise the dependent package would be left without what it needs.
This server no longer needs the reporting program, nor its setting. Which command removes both?
-
The files disappear behind dpkg's back, and the database record stays
install ok installed: a package without its program, as in the lesson on package files. -
remove keeps the
/etc/lab-pkg-report.confconffile and adeinstall ok config-filesrecord. purge removes the setting.
purge deletes the package files, its conffile and its database record. Afterwards dpkg -s lab-pkg-report says nothing is known about the package.
Key points
-
remove deletes the package files; the conffile and the record stay (
config-files). - purge deletes the conffile and the package record as well.
- dpkg will not remove a package while another installed package depends on it.