Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Particularly, I want to know what happens when I rm an open file and don't explicitly kill the process holding the file descriptor to that file. Will the file be removed when the system is shut down?

share|improve this question
up vote 3 down vote accepted

Basically, yes - whenever the process holding it open dies. Nothing "magical" happens at that point. Just like a directory entry for the file is a "hard link" to the blocks that contain that file's data, so is an open file handle. If there is no directory entry and no open file handle then the blocks are free to be reused. This means that even if you don't do a clean shutdown (eg. yank the power cord) the file will still be deleted - it was "deleted" when you ran rm, only its blocks were not immediately available for reuse.

share|improve this answer

kernel maintains a copy of the in memory file inode locked so the data blocks belonging to this file and the inode cannot be released while one process has the file open. Once the file is definitely closed (as will happen when the system is being shutdown and the process is killed), all the blocks and the inode get released for reuse. This happens before the filesystem can be unmounted (it cannot be unmounted if it has open files) and the system is shutdown.

share|improve this answer

Your Answer


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.