How to Reinstall Packages on a Linux Server

Linux has a very unique method of installing applications. Most Linux distributions rely on package management systems that download package archives containing all of the files for an application and then copy them to their correct locations. Once the files are installed, any changes you make to them can affect the functionality of the app. If you make a change that causes it to stop functioning, you may need to reinstall the package.

On a Debian-based system that uses apt-get, you can reinstall software with the following command:

# apt-get install –reinstall

Therefore, to reinstall Apache, you might type:

# apt-get install –reinstall apache2

This will re-download the package and overwrite the original installation files.

For Red Hat-based distributions that use yum for package management, you can reinstall a package as follows:

yum reinstall

To reinstall MySQL, for example, you might type:

yum reinstall mysql-server

If you are reinstalling a daemon or any other type of program that is currently running, you should restart it in order for the changes to take effect. It is also important to note that this method of reinstallation will not remove local configuration files. Therefore, if the problem is in your own configuration, you may need a different method to fix any problems you have.