I can continue playing a video after I Shift-Delete it. Is the disk-space freed when I close player?

I've noticed that I can actually Shift-Delete (ie. doesn't go to Trash) a video which is currently playing, and it still keeps on playing, even though there is no named reference to it in nautilus or ls (terminal).

Is the disk-space freed normally when the player has finished with the video?

I assume it is normal behaviour, but it is certainly a new experience for me (as this was simply not possible in Windows).


Although you've deleted it, the file is still in use because you have it open in your player. Once you close the media player, it will release its handle on the file data and will therefore be deleted.

You can verify this with the lsof command, which lists open files. If you run lsof, your movie file should be listed as being open by the player, but it will have "DEL" next to it which means it has been deleted even though it is still open.

This is actually all a useful thing and would mean you could actually recover open files that you've deleted, although that would probably be best left to another question :)

It comes about because (as I understand) files consist of the data itself, and handles (location in the filesystem) to the file. Normally you only have a single handle for a file, but you can create others using the ln command to create a hard link. This creates what appears to be an identical copy of your file but is actually just adding another handle - so you haven't used twice the disk space. You can check this by looking at the inode of the two files - this tells you where the data actually is.

So e.g. in a terminal window:

ln existing_movie.avi movie_hardlink.avi

ls -i

The -i argument to ls shows the inode information for files - they should be identical.

When you delete one of those files, the data will remain because the other one still retains a handle to the inode. Once you delete the second file, the inode has no remaining handles/references and so is deleted/marked as unused space. This is directly analogous to the case when your player has the movie open, except that the second handle here is within the running program rather than a second file in the filesystem.


read http://linuxgazette.net/105/pitcher.html, you will understand why (and learn the difference between hard and soft links)