Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
17  
Yes, restore last backup... –  sputnick Feb 18 '13 at 20:46
4  
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
1  
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. –  ultrasawblade Feb 19 '13 at 0:45

3 Answers 3

up vote 12 down vote accepted

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.

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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