ln, link

Create additional pointers to a file

ln [-fhinsv] originalFile [newlink]
ln [-fhinsv] originalFile ... link_dir
link originalFile newlink

Creates a new directory entry resulting in multiple appearances of a file, perhaps in a different directory or to provide a consistant reference for new versions of a file.

By default creates a hard link, both directory entries have the link count increased.
Specify -s to create a symbolic link if the newlink is on another volume or if originalFile is a directory.

newlink may be a directory in which to place the new link; otherwise it is placed in the current directory.
If only the directory is specified, the link will be made to the last component of source_file.

Given more than two arguments, ln makes links in link_dir to all the named source files. The links made will have the same name as the files being linked to.

-i interactivey prompts standard error with:"replace newlink?" if newlink exists.
A response from standard input begining with y unlinks ( deletes ) newlink then creates newlink.
overrides any previous -f
-f force creation if the newlink file already exists.
overrides any previous -i .
-v verbose, showing files as they are processed, as in ln -v prefix*
-h,n If the newlink_file or link_dir is a symbolic link, do not follow it. Useful with -f to replace a symlink which may point to a directory.
-s Create a symbolic link. ( no message is generated if original file does not exist! and return code is zero!)

link takes exactly two filenames and creates a hard link. No options may be supplied.

hard link vs symbolic link.

Specify -s to create a symbolic directory link.

stat on a symbolic link will return information about newlink.
stat -L displays information about the originalFile.
readlink is used to read the contents of a symbolic link and shows the path to the originalFile
See lstat,readlink,stat.


Cross-device link : use -s to create a symbolic link.
Is a directory : use -s

BUG: ln -s nofile newlink does not display a message if nofile does not exist and return code is set to 0!