Repairing after running rm -rf /*
Solution 1:
I was not root and didn't use
sudo
but a lot of my files were deleted.
You most probably have deleted only your personal settings. Create a new user and log in as that user, and check if it's all OK. It should be.
If this is the scenario you can move your files and not-missing-config-files to the new user folder.
Solution 2:
You can use this script to reinstall all your packages, it's a little hackish as I couldn't find the dpkg control mechanism without hacking around in python:
#!/bin/bash
for PACKAGE in `dpkg --get-selections | grep install | awk '{ print $1; }'`; do
sudo apt-get --reinstall install $PACKAGE
done
Save that to the file reinstall.sh
, then execute by running bash reinstall.sh
from the command line. This will take a while, but it will reinstall everything.
Solution 3:
You can make a backup of all your installed packages, then a clean install and then a restore process.
First, from a computer with all the applications preinstalled, retrieve your installed packages list and redirect the output to a file called packages.txt. Save this package list somewhere so that you can use it for the restore process.
sudo dpkg --get-selections > packages.txt
To restore all the applications from your list, you must follow a three step process very carefully.
sudo dpkg --clear-selections
sudo dpkg --set-selections < packages.txt
sudo aptitude install
You will be prompted to install all the new applications in the list. Another example of what this process allows you to do is create a baseline of all the applications after a clean installation of Ubuntu. Let’s say you would like to remove any applications installed since the clean install, perform the exact same process, and any package not defined in that list will be removed.
sudo dpkg --get-selections > clean-install-package-list.txt
sudo dpkg --clear-selections
sudo dpkg --set-selections < clean-install-package-list.txt
sudo aptitude install
The very first command of --clear-selections
marks all currently installed packages to the state deinstall
. When you restore the list of applications using --set-selections
, only packages omitted from the list will remain in the deinstall
state. Aptitude will honor the deinstall state and remove the extra packages, leaving you only with packages from the list.