Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
1  
Think twice next time before typing in some commands, especially when running them as root and especially for commands like rm -rf *... –  phoibos Sep 23 '12 at 0:40
    
@phoibos, lesson learnt. i will delete carefully if need to from next time. i was just too excited today and anything in too much obviously leads to sorrow and philosophy haha.. –  user1455116 Sep 23 '12 at 0:45
    
How about upgrading the system? –  nikhil Sep 23 '12 at 5:56
    
@nikhil that is a good idea. but i already deleted windows and installed ubuntu in my system –  user1455116 Sep 23 '12 at 15:25
    
I meant running apt-get upgrade, that might work out not sure that would work though. –  nikhil Oct 1 '12 at 10:50
add comment

2 Answers 2

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.

share|improve this answer
    
i would definitely go for a re installation. But can i reinstall it on the same 80gb memory i used install the current one? –  user1455116 Sep 23 '12 at 0:43
    
@user1455116 Yes, tell the installer to use the existing partition and to erase its content. –  Gilles Sep 23 '12 at 0:44
    
Hm, which dpkg says dpkg is in /usr/bin/dpkg, so that won't be available... –  phoibos Sep 23 '12 at 0:45
    
@Gilles how do i do that? i already tried restarting with the cd in the drive and splits my current windows memory into two, and does not show the 80gb part :( –  user1455116 Sep 23 '12 at 0:46
    
@phoibos Right, thanks, so recovery is likely to require booting to a rescue CD. –  Gilles Sep 23 '12 at 0:53
show 1 more comment

/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.

share|improve this answer
    
/usr/bin contains some programs' executables. Not all programs are there, and their data files are not there either. –  hexafraction Sep 23 '12 at 0:38
    
@Florian Diesch Hi i would definitely do that. Now i have windows 7 in one partition and ubuntu in another (80gb). Can i reinstall in the same 80gb space? –  user1455116 Sep 23 '12 at 0:41
    
@user1455116 That's the way to go. –  Ángel Araya Sep 23 '12 at 0:50
    
@user1455116 Yes. just be careful to select the right partition when installing. –  Florian Diesch Sep 23 '12 at 0:52
    
@ngel Araya im not having any option saying wipe the current ubuntu and reinstall while i start from the CD, it is creating another partition and a third OS :( –  user1455116 Sep 23 '12 at 0:52
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.