In this post we are going to discuss about the difference i.e the technical difference between Move and Copy command in linux.
As we all know the copy command is used to make the replica of a file or a directory in linux, where as the Move command it moves the file or a directory to a another location that we mention as part of the command.
What we discussed above is a theoretical difference between these commands, but how technically they are different? well, to answer this question we have to have the statistics of a file soon after the execution of the above mentioned commands.
Let me put this in a simple way to understand.... assuming we have a file named test.txt in one of the locations in the file system as given in the image below...
before we move further, I would like to discuss the details mentioned in the image
- First column of numbers is the inode number of the file/directory
- Second column tells us the privileges available on a file/directory
- Third column gives the number of links to the file/directory
- Fourth column gives the user who owns the file
- Fifth column gives the group of the user
- Sixth column is the IO Block of the file
- Seventh column gives the last modified date of the file/directory
- Eight column gives the time at the file/directory is modified
- Ninth column is the name of the file/directory
From the above details, the real candidate for consideration is the INODE number of the file/directory, this number is generated by the file system for the files/directories when they are created, but how this inode number tells the techinical difference between these two commands?
Rather talking, actions would give ample information to convince us so let us get on with it.
let me take the COPY command first...
Before we copy the file test.txt let us have the statistics of the file itself...
the image above and the previous one would have the same inode number against the file test.txt, you can check it comparing the images above
Now let us take the replica of the file test.txt i.e copying the file to another location in the file system and analyse the statistics of the file again...
As you can see the inode of the file test.txt which is available in the new location is entirely different from the previous one.
From this we can conclude that the file copied to a new location is not the same file as the one which is copied but it a replica of the old file.
Now let us try to move the file test.txt to a new location and infer the statistics...
From the above image if we look at the inode number of the file, it is same as that of the one available in the last location, from this stats we can conclude that the file which moved is the same old file and the command does not create a new file as that of the old one and deletes the old.
Hope this post helps in understanding a bit about inode, files and commands.
Post you comments and thanks.
Rather talking, actions would give ample information to convince us so let us get on with it.
let me take the COPY command first...
Before we copy the file test.txt let us have the statistics of the file itself...
the image above and the previous one would have the same inode number against the file test.txt, you can check it comparing the images above
Now let us take the replica of the file test.txt i.e copying the file to another location in the file system and analyse the statistics of the file again...
As you can see the inode of the file test.txt which is available in the new location is entirely different from the previous one.
From this we can conclude that the file copied to a new location is not the same file as the one which is copied but it a replica of the old file.
Now let us try to move the file test.txt to a new location and infer the statistics...
From the above image if we look at the inode number of the file, it is same as that of the one available in the last location, from this stats we can conclude that the file which moved is the same old file and the command does not create a new file as that of the old one and deletes the old.
Hope this post helps in understanding a bit about inode, files and commands.
Post you comments and thanks.
No comments:
Post a Comment