Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Specifically, I ran a rm -R /my/dir by mistake on a unix box (ubuntu 10.04). When I realized the horror within a few seconds I quickly killed it with the Ctrl+C command. It now seems I haven't lost any data. Is this possible? What did really happen in the background?

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

Ctrl+C send SIGINT signal to the process.

Its default action is "Abnormal termination of the process" so basically pressing Ctrl+C You are interrupting running process

If you were fast enough (before process scanned you directory structure) rm shouldn't delete anything (or maybe not if there wasn't much files in it).

share|improve this answer
add comment

You were lucky. The process has received an SIGINT, which (usually) kills the process. If you have not lost any data it is because the rm command was still busy traversing the directory structure, because it has to start deleting files in leaf directories without further subdirectories.

share|improve this answer
add comment

You are lucky if you pressed Ctrl+C fast enough to not lose any file. How did you determine you did not lose any file?

Pressing Ctrl+C will interrupt the delete process and terminate it. So, you need to double-check your files/folders and restore any deleted files.

share|improve this answer
    
It was /var/www/ so lots of files and folders, and websites. Any file missing would break at least one of them and trigger a notice. I really was lucky. And stupid! –  Damien Apr 18 '12 at 13:22
    
I agree with Khaled. You probably lost files but haven't noticed yet. –  amcnabb Apr 18 '12 at 15:51
add comment

If /my/dir contains lots of directories and files, the initial scan might take a while and it's quite possible you managed to stop your command while it was still just reading the directory structure. Other than that, Ctrl+C does not provide you any undo capabilities.

share|improve this answer
add comment

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.