Debian / Ubuntu: apt-get force reinstall package

Iam a new Debian Linux / Ubuntu Linux LTS user. How do I reinstall a package using apt-get command line? Is there an ‘apt-get force reinstall package’ command? How do I force reinstall apt-get?

The Advanced Packaging Tool (APT) works on both Debian / Ubuntu Linux. It can handle the installation and removal of software including reinstalling packages to fix problems. You need use apt-get command as follows to forcefully reinstall package. This page shows to reinstall packages on an Ubuntu and Debian server or cloud based virtual machine.

Tutorial details
Difficulty levelEasy
Root privilegesYes
RequirementsLinux terminal
CategoryPackage Manager
Prerequisitesapt-get command
OS compatibilityDebian • Mint • Pop!_OS • Ubuntu
Est. reading time3 minutes
apt-get force reinstall package
The syntax is as follows for the apt command/apt-get command to force reinstall:
# apt-get --reinstall install PackageNameHere
# apt --reinstall install pkg1
# apt-get --reinstall install Package1 Package2

The --reinstall option re-install packages that are already installed and at the newest version. This is also useful when you removed / uninstalled packages like Nginx but want to reinstall it again.
Pro tip: Backup all configuration files before reinstalling packages. For example, if you are reinstalling nginx web server package, backup /etc/nginx/ directory with the help of cp command as follows:$ sudo mkdir /root/nginx.mmddyyyy/
$ sudo cp -avr /etc/nginx/* /root/nginx.mmddyyy/

How to reinstall a package using apt-get
Let us see some example that shows how to reinstall package and its installed dependencies on a Debian or Ubuntu Linux. The following command will reinstall rsync package. Open a terminal application and then type:
$ sudo apt-get --reinstall install rsync
OR
# apt-get --reinstall install rsync

Fig.01: Debian / Ubuntu Linux reinstall a package using apt-get command
If above method failed for you, try the following syntax. Make sure you backup config file before typing the following commands. Please note that the --purge option is identical to remove except that packages are removed and purged including any configuration files are deleted too.
sudo apt-get –purge remove package1 sudo apt-get install package1
Debian or Ubuntu reinstall package command
Type the following apt command or apt-get command to reinstall htop:
# sudo apt --reinstall install htop
OR
# sudo apt-get --reinstall install htop
apt-get force reinstall package command for Debian and Ubuntu
The apt-get is the command-line tool for handling packages. The apt command provides a high-level command-line interface for the package management system. It is intended as an end user interface. Both, apt command and apt-get accepts the --reinstall option for reinstalling packages to fix problems.
apt-get reinstall package and dependencies
One can use aptitude command too. The syntax is:
$ sudo aptitude reinstall pkg
$ sudo aptitude reinstall nginx

What if I want to reinstall ALL packages …
You need to use the aptitude command as follows:
$ sudo aptitude reinstall '~i'
Conclusion
You learned how to use the apt-get to force reinstall package on a Debian and Ubuntu Linux. For more information please apt-get man page here or use the man command to read it offline on your computer:
$ man apt
$ man apt-get
$ man dpkg
$ man cp

Iam a new Debian Linux / Ubuntu Linux LTS user. How do I reinstall a package using apt-get command line? Is there an ‘apt-get force reinstall package’ command? How do I force reinstall apt-get? The Advanced Packaging Tool (APT) works on both Debian / Ubuntu Linux. It can handle the installation and…

Iam a new Debian Linux / Ubuntu Linux LTS user. How do I reinstall a package using apt-get command line? Is there an ‘apt-get force reinstall package’ command? How do I force reinstall apt-get? The Advanced Packaging Tool (APT) works on both Debian / Ubuntu Linux. It can handle the installation and…

Leave a Reply

Your email address will not be published. Required fields are marked *