Linux commands-influence of cp, mv, and rm on inode

Source: Internet
Author: User

If you are not good at writing, you may not be clear about the original meaning in some places. If you make a mistake, correct it.

In Linux, there are several common commands: cp --> copy, mv --> move/move, rm --> delete/remove.

Although we often use them, do we have a deeper understanding of these commands.

Let's take a look:

Impact of cp on inode:

1. When the replication happens, the system finds an empty inode number and writes the data to the inode table.

2. A directory will be added to correspond the file name to inode number.

3. After inode number and inode table are processed, the system will copy the file content to the new file.

 

Impact of mv on inode:

Premise: the file destination to be migrated using the mv command is in the same file system as the original file.

1. The system creates a directory item and maps the new file name to the inode number.

2. delete old files

(Moving an archive does not affect inode table or move the archive to another block)

Influence of rm on inode:

1. The system will subtract the link count number of the file and mark the corresponding inode number as usable.

==========================================================

PS:

For example, test.txt link count => 2

When rm test.txt is used,

Test.txt link count => 1

========================================================== =

2. The block occupied by the file will also be labeled with a usable "tag"

3. Finally, remove the file name and directory items.

========================================================== ====

PS:

When we use the rm command, the system does not actually Delete this document. Unless an archive is required to store the data in the block of the original archive. In this way, the original block will be overwritten by the new file.

========================================================== =====

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.