linux - Accidentally deleted my /bin folder?

24
2014-04
  • user2874316

    I was screwing around in a root terminal, and I accidentally deleted my entire /bin folder. Is this dangerous? What should I do to fix this?

    root@laptop:/# ls -l /
    total 80
    drwxr-xr-x   3 root root  4096 Oct 11 19:10 boot
    drwxr-xr-x  16 root root  3360 Oct 11 20:21 dev
    drwxr-xr-x 123 root root  4096 Oct 12 10:08 etc
    drwxr-xr-x   3 root root  4096 Dec 14  2012 home
    lrwxrwxrwx   1 root root    29 Oct 11 19:10 initrd.img -> boot/initrd.img-3.2.0-4-amd64
    lrwxrwxrwx   1 root root    30 Oct 11 18:48 initrd.img.old -> /boot/initrd.img-3.2.0-4-amd64
    drwxr-xr-x  15 root root  4096 Oct 11 18:54 lib
    drwxr-xr-x   2 root root  4096 Oct 11 18:48 lib64
    drwx------   2 root root 16384 Oct 11 18:47 lost+found
    drwxr-xr-x   3 root root  4096 Oct 11 20:21 media
    drwxr-xr-x   2 root root  4096 Dec 14  2012 mnt
    drwxr-xr-x   2 root root  4096 May  6 05:27 opt
    dr-xr-xr-x 150 root root     0 Oct 11 18:54 proc
    drwx------   4 root root  4096 Oct 11 20:40 root
    drwxr-xr-x  17 root root   680 Oct 12 10:06 run
    drwxr-xr-x   2 root root  4096 Oct 11 19:09 sbin
    drwxr-xr-x   2 root root  4096 Jun 10  2012 selinux
    drwxr-xr-x   2 root root  4096 May  6 05:27 srv
    drwxr-xr-x  13 root root     0 Oct 11 18:54 sys
    drwxrwxrwt  11 root root  4096 Oct 12 11:31 tmp
    drwxr-xr-x  10 root root  4096 Oct 11 18:51 usr
    drwxr-xr-x  11 root root  4096 Oct 11 18:55 var
    lrwxrwxrwx   1 root root    26 Oct 11 19:10 vmlinuz -> boot/vmlinuz-3.2.0-4-amd64
    lrwxrwxrwx   1 root root    26 Oct 11 18:51 vmlinuz.old -> boot/vmlinuz-3.2.0-4-amd64
    
  • Answers
  • Journeyman Geek

    Dangerous? Not any more - you already did the dangerous thing.

    You just deleted the part of the system that has essential things that belong every system needs. According to wikipedia's article on the FHS /bin contains "Essential command binaries that need to be available in single user mode; for all users, e.g., cat, ls, cp." These are MASSIVELY important in some contexts.

    Assuming you want to fix this, you might be able to copy over /bin from a running system - maybe off a livecd of the same version of your distro. I'm not totally sure this would work.

    Nonetheless, while you're trying this, back up any essential files in case anything goes wrong. /etc/ /home and /var might be goode ideas, as would /srv in distros that use it


  • Related Question

    linux - Can I recover my /opt/local/bin folder that I accidentally deleted?
  • Questioner

    I'm running Mac OS X 10.5.8. I was recently uninstalling mysql5 from /opt/local/bin.

    I typed:

    rm -rf /opt/local/bin mysql*
    

    instead of

    rm -rf /opt/local/bin/mysql*
    

    This deleted my entire /opt/local/bin directory which puts me in a bit of a bind.

    Is there any way to recover those files? If not, I have a friend that is using a similar set of programs, would it be possible to use the contents of his folder?

    If I end up needing to reinstall everything in this folder, what is the best way to go about doing this?


  • Related Answers
  • unutbu

    There is no 100% fool-proof way to recover the files. In fact, if you've left the machine running after issuing the rm command, the OS might have mistakenly viewed the disk space formerly occupied by /opt/local/bin as free space, and may have written something there. Once that happens, complete recovery becomes pretty iffy.

    Although there are data-recovery tools which one might use when such a disaster strikes, fortunately for you you lost programs, not personal data. The easiest, most sure-fire way to restore the directory is to reinstall the programs.

    PS. Welcome to the club. It is usually only after such an experience that one becomes enthusiastic about backing up!

  • random

    I reinstalled ports and all apps, etc.

    I'm back up and running and getting a good backup strategy in place.