1

I am trying to understand what it happens to a file when I move it from a directory to another, inside the same File System.

Here is the example I made up.

I have two directories and a file :

  • ~/Documents/dir1
  • ~/Documents/dir2
  • ~/Documents/dir1/fileName.txt

Here I have some details about the file fileName.txt (ls -li):

784088 -rw-r--r-- 1 myUser myUser 0 Oct 25 02:18 fileName.txt

Then, I moved the file fileName.txt from dir1 to dir2 by issuing the following command:

~/Documents/dir1$ mv fileName.txt ../dir2

and here I have the details about the file fileName.txt (ls -li) after having issued mv:

784088 -rw-r--r-- 1 myUser myUser 0 Oct 25 02:22 fileName.txt

What I expected was a change of inode number, but I was wrong . So, for what I have understood up to now, by moving a file inside the same File System:

  • the data block is not touched (that's good to me)
  • the inode (that is strange to me)

Can anyone tell me then what it changes in file properties (apart from modification time)?

Thank you in advance, really.

3

Within the same filesystem, mv-ing actually uses rename(2). So the inode will remain intact, just the inode is removed from one directory entry and attached to another.

  • 1
    hi heemayl, I do thank you, really. Your explenation is definitely clear! – fortecm Oct 25 '16 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.