[X-Unix] Utility "ln" makes a copy instead of hard link?

Eric F Crist ecrist at secure-computing.net
Fri Apr 7 12:04:34 PDT 2006


On Apr 7, 2006, at 12:16 PM, Jerry Krinock wrote:

> EXPERIMENT:
>
> 1.  Create a text file named "1.txt" containing the text "Dog".
> 2.  Create a "hard link" by the command:
>         ln 1.txt
>     Expected result: Should create a "hard link" file
>     Actual result: Error message:
>         ln: ./1.txt: File exists
> 3.  Retry to make a "hard link" by the command:
>         ln 1.txt 2.txt
>     Result: Now there are two files, 1.txt and 2.txt.
> 4.  Open 1.txt and change contents to "Cat".
> 5.  Save.
> 6.  Open "2.txt" and read it.
> 7.  Expected result: "Cat".
> 8.  Actual result: "Dog"
>
> Also, the calculated size of a directory containing a file and such  
> a hard
> link is twice the size of the one file by itself.
>
>

[snip]

Jerry,

I don't know what text editor you're using, but I think that's the  
culprit.  I'm using vi and following, exactly, your experiment  
above.  My results are that I get one file, with a hard link.  I can  
vi 2.txt, change what's there, and if I more 1.txt, I get the  
expected result.  My best guess is your text editor.  Brian's  
suggestion seems to make sense here...


-----
Eric F Crist
Secure Computing Networks
http://www.secure-computing.net





More information about the X-Unix mailing list