9

This question already has an answer here:

I noticed whenever I want to delete a folder containing a lot of data using a command line (sudo rm -r folder_name), the Terminal hangs on for the operation to terminate. But at the same time, when I manually delete a folder of similar size, the deletion is performed instantly without waiting.

Any explanation as to why this difference happens

marked as duplicate by dessert, mikewhatever, Eric Carvalho, muru command-line Oct 24 '18 at 2:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

15

When you delete from the GUI you are only moving the files to the trash bin. This updates the pointers to the files instantaneously saying that they now reside in the trash bin which is another folder.

When you delete from the command line like that it is removing the files 1 by 1 until they are all gone from within the folder then removing the folder itself. This bypasses the trash bin. This also takes longer.

If you do a Shift+Del in the GUI this will bypass the trash bin and take longer to delete.

Hope this helps!

  • 2
    For moving files to trash via command line: How to open “Trash” through terminal? – wjandrea Oct 23 '18 at 21:15
  • 3
    This updates the pointers to the files. Yes, or to be more accurate it updates directory's listing of inodes which actually are the pointers to blocks of disk space we call files. +1ed. Also if there's just minimal number of subdirectories and majority of files are there, that's gonna be faster probably, since I think it's only necessary to move subdirectory's inode to another directory's listing. Removing is recursive traversal of whole directory - that's opening syscalls, unlinking syscalls, etc, so of course longer. – Sergiy Kolodyazhnyy Oct 23 '18 at 21:26
  • @SergiyKolodyazhnyy I really do like your explanation here! Thank you! =) – Terrance Nov 20 '18 at 15:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.