(turn) Linux file Deletion principle essence explanation (Exam question Answer series)

Source: Internet
Author: User

The principle of file deletion under Linux essence explanation (Test answer series)

Description: This article is a part of the old boy Linux training exam questions and answers to share the content of the blog post, but also independent into the topic, you can click the address below to view all the content information.
http://oldboy.blog.51cto.com/2561410/791245

5. describe the principle of file deletion under Linux (3 minutes) <?xml:namespace prefix= "O" >

?xml:namespace>

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, i_nlink the amount of media connections (number of hard links), which can be understood as I_count is the memory reference counter, and 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.

For the Delete command RM, the actual reduction is the disk reference count I_nlink. There is a problem here, if a file is being called by a process and the user is performing an RM operation to delete the file, what will happen? When the user performs an RM operation to delete a file and then executes the LS or other file management commands, the file can no longer be found, but the process of invoking the deleted file continues to execute normally and the content can be read and written correctly from the file. Why is that?

This is because the RM operation only reduces the file I_nlink, if there is no other link i_nlink is 0, but because the file is still referenced by the process, so the file corresponding to the I_count is not 0, so even if the RM operation, but the system does not really delete the 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, does the RM operation delete the file after the deletion can be retrieved?

Said before, RM Operation just reduce the file I_nlink, or 0, the actual is the file name to the Inode link deleted, at this time, and not delete the file entity (Block data block), at this time, if the machine to stop work, the data can be retrieved, If you continue to write data at this time, then when the new data may be allocated to the deleted data block blocks of data, this time, the file will be really recycled, then there is no way the gods.

File system deletion and inode related cases:

File deletion Case 1:

Deep parsing of Web server disk full failures
http://oldboy.blog.51cto.com/2561410/612351

Inode Full Case 2:
passwd command error processing record due to inode node

Http://blog.sina.com.cn/s/blog_506ed9e6010106kj.html

A brief summary for everyone to check the reference.

Old boy Comment: This is the old boy's student's actual combat problem to share the experience, very precious!

From the above blog old boy teacher summed up everyone can learn knowledge points:

1) inode Knowledge

2) crontab Task wording

3)/var/spool/clientmqueue functions and potential problems and solutions.

4) strace tracking command usage tips

Tip: But these questions can be avoided in advance. The old boy Linux training course will be detailed here!

For more detailed descriptions and examples, see:

Old boy Linux OPS training-linux System File deletion principle detailed introduction

Old boy Linux OPS training-linux file system actual combat essence explanation
Old boy Linux Operations training-linux disk and file system part of the essence of the explanation
Old boy Linux OPS training-linux System file Delete recovery combat

Hint: The above class examination is the oral expression question, after class Please take the question summary note. Add 5 points for each correct question (the answer in class only points).

Answer: See the classroom old boy teacher's explanation or watch related video explanation and lesson plan

Website address: http://www.etiantian.org http://oldboy.cc

(turn) Linux file Deletion principle essence explanation (Exam question Answer series)

Related Article

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.