Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

User Commands (k - l) ln(1)
NAME
ln - Links files
SYNOPSIS
ln [ -f ][-s ] source_file target_file
ln [ -f ][-s ] source_file [ ... ] target_directory
FLAGS
-f Forces removal of existing target pathnames to allow specified links.
-s Creates symbolic links.
DESCRIPTION
The ln command links a single file source_file to file target_file or links one or more files to the
same filenames in another existing directory (target_directory). If more than two arguments are
specified and the final argument is not a directory, an error results.
By default, ln makes hard links. A hard link can only be created when all of the following are in
the same OSS fileset:
source_file
target_file or target_directory
All directories used for pathname resolution of any of the above
When the -s flag is used, ln makes symbolic links. A symbolic link can be created when
source_file and target_file or target_directory are in different OSS filesets.
If either of the following is true and the -f ag is not specified:
target_file exists
target_directory contains a file with the same name as a source_file specification
the ln command writes a diagnostic message to the standard error file, does nothing further with
the current source file, and goes on to any remaining source files.
Operands
source_file Specifies the absolute or relative pathname of the file to which the link should be
made.
The file is found through normal pathname resolution rules. When a component
of the pathname refers to a symbolic link rather than a directory, the pathname
contained in the symbolic link is resolved. If the pathname in the symbolic link
starts with a slash (/) character, the symbolic link pathname is resolved relative
to the root directory of the process. If the pathname in the symbolic link does
not start with a slash (/) character, the symbolic link pathname is resolved rela-
tive to the directory that contains the symbolic link.
If the file is not in the same OSS fileset as target_file or target_directory, a hard
link cannot be created. If resolution of the pathname for source_ file includes
symbolic links, all of the directories traversed must be in the same OSS fileset as
target_file or target_directory; otherwise, a hard link cannot be created.
target_file Specifies the relative or absolute pathname to assign to the link.
The resolved pathname for a hard link stores the inode information necessary to
provide access to source_file only within the same OSS fileset. The resolved
pathname for a symbolic link stores the filename for later resolution, regardless
of whether source_file is in the same OSS fileset.
527188-021 Hewlett-Packard Company 561