1
0 Comments

If you have a file named “foo.txt” with a size of 500 bytes and you create a new file that is 10 bytes in size and save it with the same name, the original file will be overwritten. Does the operating system, whether it’s Windows or Linux, automatically free the unused space (which is 410 bytes) in this situation?

In another scenario, if you use the dd utility to create both the old and new versions of “foo.txt,” will the operating system automatically free the unused space? It’s possible that all file writes use the same system calls provided by the operating system, which could result in consistent handling of file overwrites across different programs.

Askify Moderator Edited question April 25, 2023