Debian / Ubuntu: apt-get force reinstall package
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.
Difficulty level | Easy |
Root privileges | Yes |
Requirements | Debian/Ubuntu Linux |
Est. reading time | 2 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-get --reinstall install Package1 Package2
The --reinstall option re-install packages that are already installed and at the newest version.
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:
mkdir /root/nginx.mmddyyyy/ && 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
Sample outputs:
Fig.01: Debian / Ubuntu Linux reinstall a package using apt-get command
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
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'
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication [U2F/FIDO2]
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners part I [run Linux containers without Docker and in daemonless mode]
- How to protect Linux against rogue USB devices using USBGuard
- If your domain is not sending email, set these DNS settings to avoid spoofing and phishing
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
RSS feed Weekly email newsletter
- CentOS / RHEL: yum Command Reinstall Package
- Debian / Ubuntu Linux apt-get: Blacklist a Package
- Check Debian/Ubuntu Linux package version using
- How to get source code of package using the apt
- Debian upgrade or update a single package using apt-get
- How to use multiple connections to speed up apt-get
- Ubuntu upgrade or update a single package using apt-get
Download managers | wget |
Documentation | help mandb man pinfo |
Disk space analyzers | df duf ncdu pydf |
File Management | cat cp less mkdir more tree |
Firewall | Alpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04 |
Linux Desktop apps | Skype Spotify VLC 3 |
Modern utilities | bat exa |
Network Utilities | NetHogs dig host ip nmap |
OpenVPN | CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04 |
Package Manager | apk apt |
Processes Management | bg chroot cron disown fg glances gtop iotop jobs killall kill pidof pstree pwdx time vtop |
Searching | ag grep whereis which |
Shell builtins | compgen echo printf |
Text processing | cut rev |
User Information | groups id lastcomm last lid/libuser-lid logname members users whoami who w |
WireGuard VPN | Alpine CentOS 8 Debian 10 Firewall Ubuntu 20.04 |