-1

I am attempting to grasp hardlinks. When one copys a file from

/dir1/file1

to

/dir2/file1

does this create a hardlink, or is the data actually duplicated and now two hardlinks exist?

Oscalation
  • 1,139

1 Answers1

2

It Creates a new file when you copy. Hardlink is something different

ln fileA fileB is a hardlink.

ls -il fileA fileB

The i argument will show the inode on the HD

Here you can see that both fileA and fileB have the same inode number ( 1482256 ), also both files have the same file permissions and the same size, because that ´size´ is on the same inode it does not consume any extra space on your HD !

Now if we would remove the original fileA

rm fileA

and have a look at the content of the link fileB

cat fileB

you will still be able to read the funny line of text you typed. (MAGIC !)

AReddy
  • 3,172
  • 5
  • 36
  • 76