brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: apt install --reinstall brings back files you deleted by mistake

Apt
~/tips/tip-apt-reinstall-confmiss-restore

sudo apt install --reinstall coreutils

Reinstalls a package and restores config files that were deleted.

A deleted binary is easy to fix. A deleted config file is harder, because dpkg does not restore config files by default.

sudo apt install --reinstall coreutils
sudo apt install --reinstall -o Dpkg::Options::="--force-confmiss" nginx-common

--reinstall downloads the same version again and unpacks all files. dpkg treats config files specially: if you removed one, it respects that. --force-confmiss tells it to put back config files that are missing. The dpkg manual calls this dangerous, because it also restores files you removed on purpose. Use debsums -c (a separate package) first if you are not sure what is damaged. Afterwards, restart the affected service.

Further reading: apt manual page

More Apt tips sudo apt-mark minimize-manual apt list '~c' grep -E ' (install|upgrade|remove) ' /var/log/dpkg.log | tail -o Dpkg::Options::="–force-confold" upgrade sudo apt-get -d -y full-upgrade All Apt tips (42) All topics

Link