ln(1)

ln(1)

NAME

ln - link ®les and directories

SYNOPSIS

ln [-f][-i][-s]®le1 new_®le

ln [-f][-i][-s]®le1 [®le2 ...] dest_directory

ln [-f][-i][-s]directory1 [directory2 ...] dest_directory

DESCRIPTION

The ln command links:

®le1 to a new or existing new_®le,

®le1 to a new or existing ®le named ®le1 in existing dest_directory,

®le1, ®le2, ... to new or existing ®les of the same name in existing dest_directory,

directory1, directory2, ... to new directories of the same name in existing dest_directory,

or it creates symbolic links between ®les or between directories.

If links are to dest_directory, corresponding ®le or directory names in that directory are linked to ®le1, ®le2, ..., or directory1, directory2, ..., etc., as appropriate. If two or more existing ®les or directories (excluding destination ®le name new_®le) are speci®ed, the destination must be a directory. If new_®le already exists as a regular ®le (or link to another ®le), its contents (or the existing link) and its ACL are destroyed only if the -foption is speci®ed. The ACL on the new_®le after the link is the same as that of the source_®le ®le.

If the -fand -ioptions are speci®ed and the link being created is the name of an existing link or ordinary ®le and the access permissions of the ®le forbid writing, ln asks permission to overwrite the ®le. If the access permissions of the directory forbid writing, ln aborts and returns with the error message:

cannot unlink new_®le

(even if the ®le is an ordinary ®le and not a link to another ®le). When asking for permission to overwrite an existing ®le or link, ln prints the mode (see chmod(2) and Access Control Lists below), followed by the ®rst letters of the words yes and no in the current native language, prompting for a response, and reading one line from the standard input. If the response is af®rmative and is permissible, the operation occurs; if not, the command proceeds to the next source ®le, if any.

Hard links are created with the same ownerships and permissions as the ®le or directory to which they are linked. If ownership or permissions are changed on a link or ®le, the same changes appear on corresponding hard links. The ln command does not permit hard links to a directory.

Symbolic links are created with the ownership of the creator and the permissions are of the creator's current umask. Once created, the symbolic link ownership and permissions will not change, since the mode and ownership of the symbolic link is ignored by the system.

If ®le1 is a ®le and new_®le is a link to an existing ®le or an existing ®le with other links, new_®le is disassociated from the existing ®le and links and linked to ®le1. When ln creates a link to a new or existing ®le name, ownerships and permissions are always identical to those for the ®le to which it is linked. If chown, chgrp, or chmod is used to change ownership or permissions of a ®le or link, the change applies to the ®le and all associated links. The last modi®cation time and last access time of the ®le and all associated links are identical (see chown(1) and chmod(1)).

For a discussion of symbolic links, see symlink(4).

Options

The ln command recognizes the following options:

-fForce existing destination path names to be removed to allow the link.

-iWrite a prompt to the standard error output requesting con®rmation for each link that would overwrite an existing ®le. This option takes effect only if used in conjunction with the -foption.

-sCause ln to create symbolic links instead of the usual hard links. A symbolic link contains the name of the ®le to which it is linked. The referenced ®le is used when an open() operation is performed on the link (see open(2)). A stat() on a symbolic link returns the linked-

HP-UX Release 11i: December 2000

− 1 −

Section 1453

l