Linuxis throughLinkthe number of files to be deleted, only if a file does not exist anyLink, the file will not be deleted. In general, each file has2aLinkcounter: I_countand theI_nlink.
i_count ,i_nlink The meaning is the number of media connections (number of hard links), which can be understood as i_count i_nlink
when a file is referenced by a process, the corresponding I_count when creating a hard link to a file, the corresponding I_nlink The number will increase.
for the Delete commandRM, the actual reduction is the disk reference countI_nlink. There is a problem here, if a file is being called by a process and the user executesRMoperation to delete the file, then what will happen? when the user executesRMaction to delete the file, then executelsor other file management commands, it is no longer possible to find this file, but the process of invoking the deleted file continues to execute normally, still able to read and write the content from the file correctly. Why is that?
this is becauseRMoperation simply adds the file'sI_nlinkreduced if there are no other linksI_nlinkJust for0, But since the file is still referenced by the process, the file corresponding to theI_countNot for0, so even if the executionRMoperation, but the system did not really delete this file, when only i_nlink and i_count are 0 , the file is actually deleted. That is , you also need to dismiss the process's call to the file.
the above-mentioned I_nlink and I_count is the true condition of the file deletion, but when the file is not called, it executes the RM Do you want to retrieve deleted files after deleting files?
I said it earlier. rm operation just the file's i_nlink 0 inode block block
How Linux files are deleted