Linux · Making things work

Recovering a deleted configuration file on Ubuntu


Removing an installed package, using “apt-get remove package-name” for removing a package leaves its configuration files on the system.  In case, you have deleted a configuration file by mistake or deliberately, you cannot recover the file by doing a simple removing and adding back the package using command such as

apt-get remove package-name

and

apt-get install package-name

Installing a package second time after it has been removed via “apt remove” command shall not re-install the configuration files.

You shall need to run the following commands to restore the default configuration files that gets installed when the package is installed for the first time. “apt-get purge” is identical to remove except that packages are removed and purged (any configuration files are deleted too).Which basically tells the system that all installed configuration file for a specific application has been removed and when you run a new installation afterwards, it re-installed all packages including the configuration files.

So to a fresh installation of a package including all configuration files the following command sets shall help.

apt-get purge package-name
apt-get install package-name

This will be useful if you have deleted, corrupted or messed up the configuration beyond fixing and you don’t have the original configuration file handy.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s