Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Gilles Jun 3 '13 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 '13 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 '13 at 23:56
    
@schrobe This isn't the relevant information. Was the data in the cache before each experiment? –  Gilles Jun 3 '13 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 '13 at 1:26
add comment

1 Answer 1

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.

share|improve this answer
1  
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 '13 at 23:42
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.