deleted all the files in usr/bin typing in rm -rf *
I'm new to linux and installed Ubuntu 12.04 today. I accidentally deleted everything in /usr/bin
typing in the command rm -rf *
.
I don't know what is mounting and would like to learn but at this point I think the only way left for me is to re install everything. Please let me know the ways to re install everything now. It would be of great help to me.
Solution 1:
Since you just installed today, do the installation again. While you can recover from this, it'll be a lot more work than redoing the installation.
To recover from the deletion of /usr/bin
, you would need to reinstall all the packages that have files in that directory. You can use this command to list the affected packages:
cd /var/lib/dpkg/info
grep -l '^/usr/bin/' *.list | sed 's/\.list$//'
You'll then need to find some way of downloading the packages without relying on any of the deleted programs. Since you've deleted dpkg
, the low-level package installation utility, you'll need to obtain it from somewhere first. Grab it from some other machine running the same release Ubuntu, or download the dpkg
package on another machine and extract the programs from it. You'll need not just /usr/bin/dpkg
but also all the other programs in that package, including update-alternatives
and all the programs named /usr/bin/dpkg-*
. Again, copying might be tricky with so many programs deleted, so you may need to reboot to a rescue CD/USB to do it.
Once you have the dpkg
suite, download at least the dpkg
and apt
package somehow, perhaps on another machine or in a still-running web browser.
Then install apt
manually with the command
dpkg -i /path/to/apt_0.8.16~exp12ubuntu10.2.deb
If you get errors about missing commands, reinstall the corresponding packages first. Then reinstall all the affected packages:
apt-get --reinstall install $(grep -l '^/usr/bin/' *.list | sed 's/\.list$//')
Again, in your situation, just do a complete reinstallation.
Solution 2:
/usr/bin/
contains most of the programs that are installed on your system.
Just installing Ubuntu again would be the easiest and fastest way to get a working system again.