In short i accidentally typed sudo rm /* and now my system doesnt boot as something is deleted in / [duplicate]

I am a beginner and hence did a child's mistake and now i cant enter my system and when I try to enter recovery shell it says "Kernel panic - not syncing attempted to kill init?" and i didn't find any answer on how to solve my error online . I am desperate ...


Solution 1:

You can save your personal files (to another drive), if you have enough drive space, save the whole file tree /home preserving the ownership and permissions.

  • Simple example, boot from another system, for example a live system in a USB drive, mount the partition of your broken installed system to a mountpoint and backup to a tarball,

    cd /mountpoint
    sudo tar -cvf /path/home-backup.tar home
    
  • Maybe make a compressed tarball (slower, but needs less drive space),

    cd /mountpoint
    sudo tar -cvJf /path/home-backup.tar.xz home
    

Then you can re-install and later on restore your settings and personal files from the [compressed] tarball.

You can restore by

  • Change directory to /

    cd /
    
  • Run the following command to extract everything from the tarball,

    sudo tar -xvf /path/home-backup.tar
    

    or

    sudo tar -xvf /path/home-backup.tar.xz