Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Reinstall a Package with apt-get on Debian

Put a broken package back to a clean state without removing it first.

VPS and Cloud Servers1 min read4 screenshots

When to reinstall

apt-get reinstall installs a package again, even if it is already there. Use it when:

  • Files of a package are damaged after a failed update.
  • You changed a config file by mistake and want the default back.
  • A package has dependency problems.
  • A package was removed only in part.

Syntax

sudo apt-get reinstall package_name

You can list several packages, separated by spaces.

Examples

Restore the default settings of Nginx

sudo apt-get reinstall nginx
Reinstalling nginx
Note: Reinstalling restores missing config files. To overwrite files that you edited, add the option -o Dpkg::Options::="--force-confmiss,confnew", or move your own file away first.

Fix a package that no longer works

sudo apt-get reinstall htop
Reinstalling htop

Fix dependency problems

sudo apt-get reinstall curl

Reinstall the Vim editor

sudo apt-get reinstall vim
Reinstalling vim

Reinstall several packages at once

sudo apt-get reinstall git wget
Reinstalling git and wget

Helpful tips

  • Run sudo apt-get update first so you get the newest package lists.
  • Back up your config files before you reinstall.
  • If the reinstall fails, try sudo apt-get install -f to repair broken dependencies.

Quick recap

  • Use sudo apt-get reinstall package_name to repair a package.
  • Update the package lists first and keep a copy of your config files.