Sometimes files in the package gets corrupted or accidentally modified - yet APT still considers it "installed". In such cases, you can force a clean reinstallation. This tutorial demonstrates how to reinstall packages using APT.
APT provides the --reinstall
option, which forces the reinstallation of the specified package. For example:
sudo apt install --reinstall -y curl
This command downloads the package again from the repository and reinstalls it over the existing version, replacing any modified or missing files. It's a useful way to recover from corruption without having to manually remove and install the package.
You will see output similar to the following:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 226 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 curl amd64 8.5.0-2ubuntu10.6 [226 kB]
Fetched 226 kB in 1s (333 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 5122 files and directories currently installed.)
Preparing to unpack .../curl_8.5.0-2ubuntu10.6_amd64.deb ...
Unpacking curl (8.5.0-2ubuntu10.6) over (8.5.0-2ubuntu10.6) ...
Setting up curl (8.5.0-2ubuntu10.6) ...
Note: The --reinstall
option does not remove user configuration files or system-wide settings. To fully reset a package's configuration, you may need to purge it - removing both the package and its configuration files - before reinstalling it from scratch.
You can also reinstall multiple packages in one command by listing them together:
sudo apt install --reinstall -y curl wget
This is useful when you need to refresh several related tools or restore a standard development environment.
Leave a Comment
Cancel reply