How to *really* remove a file?
Chris Green
cl at isbd.net
Thu Jan 5 08:24:46 UTC 2023
On Thu, Jan 05, 2023 at 09:19:11AM +0100, Bo Berglund wrote:
> I have noted that on Ubuntu if I have a file and run:
>
> rm filename
>
> the file vanishes from sight (is no longer listed by ls or the like) but it
> seems to still exist!
>
> For example if I have a process logging to the file when I run the rm command it
> still continues to log (invisibly) to the now removed file instead of creating
> the file anew and log to the new (same name) file.
>
> Same if I don't rm it but instead mv it to a new name, then the logging
> continues into the new name of the old file.
>
That's exactly how it's expected (meant?) to work. Once a process
has a file descriptor open it uses that to access the file and no
longer looks at the directory entry (which is what ls reports) at all.
Only when the file descriptor is no longer in use will the 'file' (as
in the space on the storage device) be made available for re-use.
Why would you want it otherwise?
--
Chris Green
More information about the ubuntu-users
mailing list