10

I witnessed that deleting directories (with the size of a couple of gigabytes) which contain many files is very slow when using rm. It takes up to several minutes!
When deleting the same folder via the File Manager, the job is done within a second. (It takes another second to empty the trash afterwards.)

What is the reason for this?

6
  • How did you do the experiment? Were you starting from an empty disk cache or with all the directories in the cache both times? If rm had to load everything from disk but the file manager did everything in memory, that would explain the difference. Jun 3, 2013 at 21:47
  • A directory (~5 GB) on an external USB hard drive containing more than 3000 Files and a lot of sub-directories.
    – schrobe
    Jun 3, 2013 at 23:49
  • Hmmm... next time you try to delete a folder with many files, try deleting using SHIFT+DELETE key on that folder. It will ask if you want to permanently remove those files. That will then show you a progress bar showing you how long it takes to delete. You should notice that it takes just as long as rm does. AFAIK file-managers just use rm in the background.
    – hazrpg
    Jun 3, 2013 at 23:56
  • @schrobe This isn't the relevant information. Was the data in the cache before each experiment? Jun 3, 2013 at 23:56
  • I don't know. I didn't access the directories before, so I guess not. Anyway, this wasn't a real "experiment" but I could see significant differences. Since it turned outthere is no trivial answer, I can set up an "experiment" and precisly measure the time (and ensure the same memory conditions).
    – schrobe
    Jun 4, 2013 at 1:26

1 Answer 1

11

The rm command actually removes the files, File Manager only moves the files to the trash. It is only when you empty the trash that you see the actual time that rm took to delete the files. So put simply, moving files is quicker than deleting. File Manager moves files while rm removes them.

2
  • 4
    But as I said: Emptying the trash doesn't talk long either. My guess: Clearing the trash does actually take a long time, but it is shown empty even though the rm command is still running in the background.
    – schrobe
    Jun 3, 2013 at 23:42
  • But rm simply unlinks the files, no?
    – lindhe
    Apr 6, 2018 at 7:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .