Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try rm -rf on a directory which has a lot of subdirectories and/or files and which is mounted with SSHFS, then I takes a while to execute.

Is it normal ?

I would like to know how rm -rf works internally, at the Files System level.

Does it only remove the directory, or does it go through all directory/files ? That would explain why it so slow...

share|improve this question
When I read the title "How works rm -rf? I hear Yoda's voice as the narrator. :-) – Somantra Jul 3 '12 at 18:25
You may be able to speed up the removal by ssh-ing into the remote system and executing the rm -rf there. – Brian Swift Jul 3 '12 at 19:34
@Somantra: Sorry that's the french sentence construction :p – charles Jul 3 '12 at 20:54
@BrianSwift Thanks for the tips, that's exactly what I did. I just wanted to be sure that I correctly understand the problem. – charles Jul 3 '12 at 20:54
@Somantra: I get an Insane Clown Posse vibe, myself. – womble Jul 4 '12 at 6:00
up vote 6 down vote accepted

The -r switch acts exactly how its name implies: recursively. It executes the same action on each and every file and directory inside the current directory, before removing it.

So, yes, being quite slow for large (as in "with lots of different things inside") directories is absolutely normal.

One of the biggest (and most feared) signs you mistyped a rm -rf command and are actually destroying your root partition is an overly long execution time...

share|improve this answer
@charles And it's going to be even worse with the sshfs that you mentioned, as you'll be adding in network latency, on top of any disk latency the server is experiencing while executing the rm. – cjc Jul 3 '12 at 18:44
that's my problem :p – charles Jul 3 '12 at 20:56

Yes, the command is recursive.

From man rm

-r, -R, --recursive

remove directories and their contents recursively

share|improve this answer

Your Answer


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.