link vs ln

what is the difference between the two? What is the difference between hard link and symbolic link? the QNX doc mentions that “The link command can be very dangerous to your filesystem; you should probably use ln instead”, why is this?

So if I do: link /dev/shmem /tmp
vs
doing this: ln -sP /dev/shmem /tmp

thanks

A soft link is like a direction while shopping: You can find watches right over the street…

A hard link is more like i would be reselling the watches from over the street in my own shop.

The symbolic link does not really require the source to be valid or to stay valid, it can also be a directory (Following a dead link does not work anyway). The symbolic link is more like a sign where to find the real source.

A hard link has to have a valid source and can only be a file. As soon as your source is invalid there is no hard link anymore. hard links can also not be set to cross partition borders or device borders.

More common:
A soft link is a storage for the path to the source.
A hard link is another filename for the same data.

I will stop finding explenations now ^^

so if I want to creat a shortcut to the whole directory instead of just single file I can’t use hard link and should use soft link?

Meaning I shouldn’t do “link /dev/shmem /tmp” but rather “ln -sP /dev/shmem /tmp”

Yes use ln cause you are crossing device boundaries. You also don’t have to use ln’s -P option unless you don’t want to make it permanent.

Note that having /tmp point to /dev/shmem is dangerous, certain operation like creating a directory aren’t supported by /dev/shmem

so what does -P option really mean? Can you explain in more detail?

Check
qnx.com/developers/docs/6.4. … /l/ln.html

That’s the spirit, don’t feed them fish but teach them how to fish, LOL!