Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)
User Commands (k - l) ln(1)
The value specified for target_file is resolved using normal pathname resolution
rules. target_file file must be in the same OSS fileset as source_file if you are
trying to create a hard link. If resolution of the pathname for target_file includes
symbolic links, all of the directories traversed must be in the same OSS fileset as
source_file; otherwise, a hard link cannot be created.
target_directory
Specifies the relative or absolute filename of a directory in which links for the
specified source_file values should be created. target_directory must be in the
same OSS fileset as source_file if you are trying to create hard links.
The value specified for target_directory is resolved using normal pathname reso-
lution rules. If resolution includes symbolic links, all of the directories traversed
must be in the same OSS fileset as source_file; otherwise, a hard link cannot be
created.
EXAMPLES
1. To create a hard link to a file, enter:
ln chap1 intro
This links file chap1 to the new filename intro,ifintro does not already exist.
2. To create the link in Example 1 if intro already exists, enter:
ln -f chap1 intro
Now chap1 and intro are two filenames that refer to the same file. Any changes made to
one also appear in the other. If one name is deleted with the rm command, the file is not
actually deleted but remains under the other name.
3. To create a hard link for the file named index to the same name in another directory that
has the filename manual,enter:
ln index manual
This links file index to the new name manual/index.
Note that intro in Example 1 is the name of a file; manual in Example 2 is a directory
that already exists.
4. To create hard links for several files to names in another directory in the same OSS
fileset, enter:
ln chap2 jim/chap3 /u/manual
This links file chap2 to the new name /u/manual/chap2 and file jim/chap3 to
/u/manual/chap3.
5. To use the ln command with pattern-matching characters, enter:
ln manual/* .
This links all files in the directory manual into the current directory (.), giving them the
same names they have in manual. Note that you must type a space between the * (aster-
isk) and the . (dot).
527188-004 Hewlett-Packard Company 5−61