Ubuntu Main Menu
| How to Reinstall all Installed Applications Without Reinstalling Ubuntu |
|
|
|
Written by myOltrans
Wednesday, 11 November 2009 13:41
If you need to reinstall your applications due to whatever reason, use this instructions. I just deleted some files in the lib folder and do not know what exactly are those files. So I do not know which application to reinstall. Reinstalling all applications will insure that all the neccessary files are in the lib folder. Here is a script that uses dpkg to iterate through and reinstall all packages listed as installed by the package management database. Each package is installed individually; this gets around "package x pre-depends on package y" errors. Also, the script skips certain packages, namely apt- and dpkg- related packages (because you don't want your package manager to change mid-stream), and packages relating to mysql and mythtv (because these packages don't take too well to non-interactive configuration), also packages that have deinstall status ("| egrep -v deinstall"). Feel free to add your own additional exception patterns to the egrep command embedded within the script. Because the script reinstalls packages one at a time, it isn't fast, but it does get the job done. On an Intel 2.4GHz Q6600 with 2GB of RAM, a fast SATA-II drive, and using Ubuntu Gutsy (64-bit), the script will reinstall anywhere from 250 to 750 packages an hour, depending on the state of the package cache and other factors. To use the script, follow the steps below: Step 0: Backup all of your data. Step 1: Open a plain text editor, and copy/paste the following code:
#!/bin/bash for pkg in `dpkg --get-selections | egrep -v deinstall | awk '{print $1}' | egrep -v '(dpkg|apt|mysql|mythtv)'` ; do apt-get -y install --reinstall $pkg ; doneImportant: The commands "for pkg ... done" should all be on the same line. Step 2: Save the file with an appropriate name, such as: reinstall_all.sh Step 3: Open a Bash shell, change the script's owner to "root", and make it executable: sudo chown root:root reinstall_all.sh sudo chmod 755 reinstall_all.sh Step 4: Execute the script: sudo ./reinstall_all.sh I hope this helps... Script based upon solution presented by Tod Detre on debianHELP.org at 2007-09-20 17:00. http://www.debianhelp.org/node/10487 Source: here. |


