How to Use apt-get reinstall on Debian and Ubuntu

October 22, 2020


When files in a package are modified or accidentally removed, it can damage the system. Installing the package again resolves the problem in most cases. However, using the apt-get install command will return an error, given that the package is already present.

The --reinstall flag is a shortcut for an apt-get command used to reinstall packages, using the most up-to-date versions. This is useful for packages with many reverse dependencies.

In this tutorial you will learn how to use apt-get reinstall to reinstall packages on Debian and Ubuntu.

How to use apt-get reinstall on Debian and Ubuntu

Note: Using the --purge remove option to remove packages and installing them again achieves similar results. However, it also erases configuration files.


  • An account with sudo privileges
  • Access to the command line/ terminal
  • A Debian/Ubuntu system

Reinstall Packages Using apt-get

Using the --reinstall command is a simple process. The syntax is as follows:

sudo apt-get --reinstall install PackageName

If you wish to reinstall more than one package, you can list them all in one line:

sudo apt-get --reinstall install PackageName1 PackageName2

Reinstall htop Using apt-get

This is how to reinstall htop, an interactive process viewer on Ubuntu, using the --reinstall flag.

sudo apt-get --reinstall install htop

The output should look like this:

Reinstall htop using apt-get

Reinstall Packages Using aptitude Command

Aptitude is a graphical user interface for the apt package manager. However, it can be used with the command line too.

If you wish to reinstall a package with aptitude, use the following syntax:

sudo aptitude reinstall PackageName
Reinstall a package using the aptitude command

Note: Use sudo aptitude reinstall '~i' command if you wish to reinstall ALL packages.

Reinstall apt After You Accidentally Removed It

If you accidentally remove apt, for example by purging it using --force-* option, install it again in three simple steps:

1. Go to to search for the release of your choice. Avoid testing or unstable releases.

2. Choose the version number and download the package for your architecture.

Download the apt package for your architecture

3. In terminal, run:

sudo dpkg -i apt_0.5.4_i386.deb

Replace the version and architecture in the example as necessary.

Install the apt package


After reading this article, you should be able to reinstall packages using both apt-get and aptitude commands, as well as to restore apt itself if it is removed accidentally.

For more details on the apt package manager, read our article on how to manage packages on Ubuntu.

Was this article helpful?
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
APT vs APT-GET: What's the Difference?
June 25, 2020

Since Linux introduced the apt command line tool with the Ubuntu...
Read more
How to Fix "add-apt-repository command not found" on Ubuntu & Debian
March 21, 2024

This guide shows you how to fix the 'add-apt-repository...
Read more
How to Use The APT-GET Command In Linux
May 6, 2019

Advanced Package Tool (APT) is a package management system...
Read more
How to use apt Package Manager on Ubuntu Linux
January 7, 2019

In Linux, special tools were developed for managing applications. Application...
Read more