3

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

stew
  • 9,388
  • 1
  • 30
  • 43
Charles
  • 185
  • 2
  • 8

2 Answers2

6

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

Massimo
  • 70,200
  • 57
  • 200
  • 323
  • 2
    @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 03 '12 at 18:44
  • that's my problem :p – Charles Jul 03 '12 at 20:56
2

Yes, the command is recursive.

From man rm

-r, -R, --recursive

remove directories and their contents recursively

unhappyCrackers1
  • 977
  • 1
  • 6
  • 18