How to reinstall a package using 'apt-get'?

$ man apt-get | grep reinsta -A2
       --reinstall
           Re-Install packages that are already installed and at the newest
           version. Configuration Item: APT::Get::ReInstall.

So, to use it to reinstall aptitude use:

sudo apt-get install --reinstall aptitude

You can reinstall a package with sudo apt-get install --reinstall packagename. This completely removes the package (but not the packages that depend on it), then reinstalls the package.

This can be convenient when the package has many reverse dependencies.


Sometimes you need to restore config files too! not just reinstall.

sudo apt-get install --reinstall xxxx

Reinstall the application, keeps the config files.

This could be helpful, but sometimes you need to start fresh, so what I use is this:

sudo dpkg -r xxxx //to remove that xxxx package
sudo dpkg -P xxxx //to purge all related files

then

sudo apt-get install xxxx