Reinstalling the same archive brings back a missing package file. Your own settings survive it.
sudo dpkg -i <archive> unpacks the files again, over whatever is left, and checks the dependencies once more. The archive must be the same version as the installed one: dpkg -s and dpkg -I show both. apt keeps downloaded archives in /var/cache/apt/archives: from there you could, for example, bring back the tree files.
dpkg handles settings more carefully. A settings file the package declared as its own — a conffile — is not overwritten if you changed it: your edit stays. dpkg -s lists such files in the Conffiles field.
Do not edit records in /var/lib/dpkg/status by hand for the sake of a "correct" state: the files will not come back, and the package database will stop matching the system.
You deleted the /etc/lab-pkg-report.conf conffile and installed the same lab-pkg-report archive again. What happens to the settings file?
-
dpkg silently leaves a deleted conffile deleted. It asks when both you and a new package version changed the setting.
-
dpkg treats a deleted conffile as your edit, just like a changed one. After installation
ls -l /etc/lab-pkg-report.confstill printsNo such file or directory.
To dpkg a deleted conffile is a local edit too, so a reinstall does not bring it back. sudo dpkg -i --force-confmiss <archive> restores the shipped version.
Key points
- Reinstalling the same archive brings back the package files.
- dpkg does not overwrite a conffile you changed.
- Use an archive of the installed version; do not edit database records by hand.