How Linux files are deleted

Source: Internet
Author: User

Linux File Deletion principle:

Linux is controlled by the number of link to delete the file, only if a file does not exist any link , the file will be deleted. In general, there are 2 link counters for each file: I_count and i_nlink.

The meaning of I_count is the number of users (or calls) of the current file , and the meaning of I_nlink is the number of media connections (number of hard links), which can be understood as I_count is a memory reference counter,I_nlink is the reference counter for the disk.

When a file is referenced by a process, the corresponding number of I_count is incremented, and the corresponding i_nlink number is incremented when a hard link to the file is created .

& Nbsp;    for the delete command rm i_nlink rm The operation has deleted the file, then what will happen? rm After you delete the file, execute the ls

This is because rm operation just the i_nlink If there is no other link i_nlink 0 0 So even if you do rm operation, but the system does not really delete this file when only I_ Nlink i_count all 0

the above-mentioned I_nlink and I_count is the true condition of the file deletion, but when the file is not called, does the RM operation Delete the file after the deletion can be retrieved?

previously said,the RM operation only reduces the i_nlink of the file , or 0, the actual is to delete the file name to the Inode link, at this time, the entity is not deleted ( block data block), at this time, if the time to stop the machine work, the data can be retrieved, if you continue to write data, then when the new data may be allocated to the deleted data block blocks of data, at this time, the file will be really recycled, Then there is no way to be immortal.


How to delete linux files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.