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.
========================================================== =====