0

Is there a way to recover removed files in a situation such as described below? The command I executed was:

root@system:/# rm -r /tmp/letsencrypt.sh-XXXXXX l*

I tried to remove all the files in that directory that started with an l. When I noticed what I did it was too late, I know, pretty stupid...

I quickly made a snapshot after. Does anyone know some way to save my system? Or how I can search for files in it? It seems ls is also gone:

root@system:/# ls /tmp
bash: /bin/ls: No such file or directory

root@au-dev:/# echo *
bin boot dev etc home initrd.img media mnt opt proc root run sbin snap srv sys tmp usr var vmlinuz
11
  • 3
    Bad news: you need to reinstall your system. You have deleted every file in the system that starts with 'l', including all program libraries (typically starting with 'lib'). – Jos Jun 20 '16 at 18:16
  • 3
    Use a live USB, choose "Try Ubuntu", and back up all your user data to a safe place. Then reinstall Ubuntu. – Jos Jun 20 '16 at 18:18
  • Follow Jos comment and re-install without formatting any of the partitions. If it works you get your system back. Otherwise do a re-install with a restore of said backup – Rinzwind Jun 20 '16 at 18:25
  • 4
    Please edit your question and show us the output of cd /; echo *. I don't see why that command would have removed ls. It would have removed all your /lib directories, effectively breaking your system, but all of your data and files should be fine. – terdon Jun 20 '16 at 18:25
  • I thought that was interesting too, @terdon. I can confirm, that command does remove ls, and the l* directories. – user508889 Jun 20 '16 at 19:51
0

Is there a way to recover removed files in a situation such as described below?

Technically, yes for example using testdisk. However, it is not worth it. You basically deleted some system files (the entire /lib and /lib64 directories) but not your user data.

Therefore, you are better off just making a copy of your home directory and reinstalling from scratch. I have described how to back up files using a live CD in this answer, here's an excerpt:

Backup using a live DVD or USB

If you have access to a Ubuntu installation medium, do the following:

  • boot your computer using the live DVD or USB
  • connect the external hard drive
  • run sudo nautilus in the terminal
  • copy all the files you want in the external drive
  • safely disconnect the drive
  • re-install Ubuntu

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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