Score:0

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

cn flag

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

Organic Marble avatar
us flag
Reinstall the system and reload your backups.
nobody avatar
gh flag
Install anew. I hope you have a backup from your personal data.
Shreyas Devesh avatar
cn flag
i have installed many things and everything is intact but the symlinks and some other files were lost but i dont know how to add those symlinks that were deleted through live USB . The issue is that i cant enter my system but every program,every file exists . i didnt use "sudo rm -r /*" i just did sudo rm /* so no folders containing files were deleted
sudodus avatar
jp flag
Most of us have done things like this. We all learn from our mistakes. It is a very good idea to set up a backup routine ;-)
Shreyas Devesh avatar
cn flag
i have installed many things and everything is intact but the symlinks and some other files were lost but i dont know how to add those symlinks that were deleted through live USB . The issue is that i cant enter my system but every program,every file exists . i didnt use "sudo rm -r /*" i just did sudo rm /* so no folders containing files were deleted
cc flag
The links, sbin, bin, lib, lib64, lib32, libx32 all go to /usr/<same name>. Just replace them. e.g. sudo ln -s /usr/bin /bin
Nmath avatar
ng flag
We understand that you didn't run the recursive flag. What you did is still fatal and requires a reinstall.
cn flag
Addition to what is told above: reinstall WITHOUT formatting. That will leave all personal configuration as is.
muru avatar
us flag
Does this answer your question? [Undo sudo rm -R /\*](https://askubuntu.com/questions/555550/undo-sudo-rm-r)
Score:2
jp flag

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
    
Score:0
pk flag

ooooh im sorry to say hear this well better than trying to fix something u have no idea where to begin u can use

bootable usb stick to recover ur files then reinstall mostly wont be necessary unless u installed the entire system in /

also next time create partions if u havent already

/
/boot
/var
/home

so that so can reinstall and change only specific partions during installation

or use system recovery image to do the same from the bootloader

will have to probably reinstall also keep backups

Instead of using

rm -rf * postfix.txt # accidental space between

would delete all files

The file name used within quotes is considered as a single file this will avoid errors like what u did

rm -rf '* postfix.txt'   

on the other hand wont delete bc file by the name *\ postfix.txt doesnt exist

better to use find command

find . -name "* foldername/" -type d -exec rm -rf {} \;

or 

find . -name "/foldername/ *" -type d | xargs -0 rm -r

Here,

-name = name of file

  -type = f for file , d for directory

  -exec = to execute commands followed {contains the output from search} \;slash is for closing 


   | = (pipe operator) used to join two commands like joining a pipe

   xargs = is used to execute commands
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.