How to restore a single file from a package?
How can I do this without reinstalling the rest of the files as well?
Download the package, for example transmission-daemon
, with
sudo apt-get --download-only install transmission-daemon
unpack the package with
mkdir ~/dummy
dpkg-deb -x /var/cache/apt/archives/transmission-daemon_*.deb ~/dummy
restore the file, for example /etc/init.d/transmission-daemon
sudo cp ~/dummy/etc/init.d/transmission-daemon /etc/init.d
remove the dir
rm -rf ~/dummy
I know this is a bit old, but here's my improvement:
$ sudo apt-get download <package-name>
instead of
$ sudo apt-get --download-only install <package-name>
I had a situation where the package was already installed (hence, the proposed solution didn't work), and I wanted to restore just one config file, in order to fix the problem.
Cheers