I just ran rm /* accidentally, any fix?

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


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.


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.

  • http://www.cyberciti.biz/tips/linux-ext3-ext4-deleted-files-recovery-howto.html
  • http://extundelete.sourceforge.net/

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