5

This has been mentioned in this question here: What's the difference between alias and link?

But I am not even sure what I am looking for. I wish to create a hard link of the type where if a program 'uses' it in the specified directory, it will actually use it from the other central location.

Does something like that exist? For example, would I create ln /path/from/file /path/from/file?

The above command does something like it I believe.

4
  • Suggest you open Terminal and read man ln
    – douggro
    Jan 18, 2015 at 18:14
  • What do you mean " use it from the other central location" Only the file open cares where the file is - after that it is just a handle
    – mmmmmm
    Aug 3, 2015 at 21:09
  • @Mark Thanks for your comment. I am asking about whether a hard link tells the program that is being fed this hard link to modify the original file and work with the file as though I had specified its original location. So does a hard link completely mimic a copy of a file?
    – Hirek
    Aug 6, 2015 at 8:55
  • A hard link does not mimic a copy - it is the same file accessed via another address - you can't tell which is the original address and after opinion or what its address was at all
    – mmmmmm
    Aug 6, 2015 at 9:03

1 Answer 1

12

Both hard links and symbolic links link a path to a destination, however there is a substantial difference you should be aware of:

  • Hard links link a path to a file. This means that if you rename/move the destination file, the hard link follows.
  • Symbolic links link a path to a path. This means if you rename/move the destination file, the link is broken. However, later replacing the file with a different one will make the link work again.

Links of both types are made with the ln tool. Hard links are made without any options, whereas symlinks are made with the -s option.

For more information on constructing the command, see:

2
  • Thank you so much @grgarside . Now, let's hope the software program that is supposed to use this hard link does not mistakenly read out the link file which my program tried to do with an alias. It seems that aliases are solely created for the sake of a user clicking on it not for other programs to use them
    – Hirek
    Jan 18, 2015 at 18:48
  • A bit more succinctly, a hardlink is a file that has the same inode (well, almost in the HFS+ filesystem) as the source file. If you delete the source file then the hardlink file is still a valid file.
    – fd0
    Aug 3, 2015 at 21:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .