ln - link files
ln [-f] source_file target_file ln [-f] source_file... target_dir
In the first synopsis form, the ln utility will create a new directory entry (link) for the file specified by the source_file operand, at the destination path specified by the target_file operand. This first synopsis form is assumed when the final operand does not name an existing directory; if more than two operands are specified and the final is not an existing directory, an error will result.
In the second synopsis form, the ln utility will create a new directory entry for each file specified by a source_file operand, at a destination path in the existing directory named by target_dir.
If the last operand specifies an existing file of a type not specified by the XSH specification, the behaviour is implementation-dependent.
The corresponding destination path for each source_file will be the concatenation of the target directory pathname, a slash character, and the last pathname component of the source_file. The second synopsis form will be assumed when the final operand names an existing directory.
For each source_file:
- If the destination path exists:
- If the -f option is not specified, ln will write a diagnostic message to standard error, do nothing more with the current source_file, and go on to any remaining source_files.
- Actions will be performed equivalent to the XSH specification unlink() function, called using destination as the path argument. If this fails for any reason, ln will write a diagnostic message to standard error, do nothing more with the current source_file, and go on to any remaining source_files.
- Actions will be performed equivalent to the XSH specification link() function using source_file as the path1 argument, and the destination path as the path2 argument.
The ln utility supports the XBD specification, Utility Syntax Guidelines .
The following option is supported:
- Force existing destination pathnames to be removed to allow the link.
The following operands are supported:
- A pathname of a file to be linked. This can be a regular or special file; whether a directory can be linked is implementation-dependent.
- The pathname of the new directory entry to be created.
- A pathname of an existing directory in which the new directory entries are to be created.
The following environment variables affect the execution of ln:
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Used only for diagnostic messages.
The following exit values are returned:
- All the specified files were linked successfully.
- An error occurred.
chmod, find, pax, rm.