I fell so stupid...

I just ran rm /* accidentally, but I meant rm ./* on a cloud server with root access.

Now, no one command works. ls, ssh, sftp... none.

Is there a way to fix that? (Note: params like -r or -f are no used in this case).

  • 19
    Yes, restore last backup... – Gilles Quenot Feb 18 '13 at 20:46
  • 5
    And after restoring, alias rm to rm -i, at least for a while :-) – jaume Feb 18 '13 at 22:56
  • 2
    Also, if deleting all the files in the current directory is something you do often, get in the habit of saying rm * –– the ./ is totally unnecessary and, as you’ve experienced, can lead you into trouble. – Scott Feb 18 '13 at 23:43
  • 3
    Just because you did something stupid doesn't make the question less valuable. +1 from me. – 0xC0000022L Feb 19 '13 at 0:44
  • ls before rm. – LawrenceC Feb 19 '13 at 0:45

Restore from backup.

Depending on the filesystem you may be able to run an undelete or recovery utility, but it's likely easier and more reliable to just restore from a backup.

| improve this answer | |

Backup is likely your best fix, however if that isn't an option for whatever reason there are some techniques that can help recover deleted files from ext3/4 partitions.

For any of these methods to be effective you want to drop to single user mode and unmount the disk(s) as soon as possible. And preferably run these from a livecd or other recovery environment is also a significantly safer method to avoiding accidental data loss while trying to recover your data.

I won't post an epic on undelete processes as you should try to use the backups first, here are the links I find most helpful.

| improve this answer | |
  • Of course you need to be able to stop using and unmount the affected volume as soon as possible if you want to go this route. – dmckee --- ex-moderator kitten Feb 19 '13 at 2:22
  • @dmckee your totally right, Should have mentioned it. (adds warning line) – Techdragon Feb 19 '13 at 2:47

If the rm didn't eat too much (when it happened to me, I killed it when it was halfway through /bin...), you can start the machine in rescue mode, check what packages are affected (in rpm's case, rpm -Va tells you), and reinstall those.

Be advised that this only works on new moon, after midnight. A short rain dance beforehand might be beneficial. Or not. YMMV.

(Yes, this is Unix' brutal way of teaching unsuspecting users to consider each command carefully before pressing ENTER. Consider yourself taught.)

| improve this answer | |

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.