Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (HP-UX-11.11)
Apropos / Subsearch:
optional field

 ln(1)								       ln(1)

      ln - link files and directories

      ln [-f] [-i] [-s] file1 new_file

      ln [-f] [-i] [-s] file1 [file2 ...] dest_directory

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

      The ln command links:

	   +  file1 to a new or existing new_file,

	   +  file1 to a new or existing file named file1 in existing

	   +  file1, file2, ...	 to new or existing files 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 files or between

      If links are to dest_directory, corresponding file or directory names
      in that directory are linked to file1, file2, ..., or directory1,
      directory2, ..., etc., as appropriate.  If two or more existing files
      or directories (excluding destination file name new_file) are
      specified, the destination must be a directory.  If new_file already
      exists as a regular file (or link to another file), its contents (or
      the existing link) and its ACL are destroyed only if the -f option is
      specified.  The ACL on the new_file after the link is the same as that
      of the source_file file.

      If the -f and -i options are specified and the link being created is
      the name of an existing link or ordinary file and the access
      permissions of the file forbid writing, ln asks permission to
      overwrite the file.  If the access permissions of the directory forbid
      writing, ln aborts and returns with the error message:

	   cannot unlink new_file

      (even if the file is an ordinary file and not a link to another file).
      When asking for permission to overwrite an existing file or link, ln
      prints the mode (see chmod(2) and Access Control Lists below),
      followed by the first 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 affirmative and is

 Hewlett-Packard Company	    - 1 -   HP-UX Release 11i: November 2000

 ln(1)								       ln(1)

      permissible, the operation occurs; if not, the command proceeds to the
      next source file, if any.

      Hard links are created with the same ownerships and permissions as the
      file or directory to which they are linked.  If ownership or
      permissions are changed on a link or file, 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 file1 is a file and new_file is a link to an existing file or an
      existing file with other links, new_file is disassociated from the
      existing file and links and linked to file1.  When ln creates a link
      to a new or existing file name, ownerships and permissions are always
      identical to those for the file to which it is linked.  If chown,
      chgrp, or chmod is used to change ownership or permissions of a file
      or link, the change applies to the file and all associated links.	 The
      last modification time and last access time of the file and all
      associated links are identical (see chown(1) and chmod(1)).

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

      The ln command recognizes the following options:

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

	   -i	   Write a prompt to the standard error output requesting
		   confirmation for each link that would overwrite an
		   existing file.  This option takes effect only if used in
		   conjunction with the -f option.

	   -s	   Cause ln to create symbolic links instead of the usual
		   hard links.	A symbolic link contains the name of the
		   file to which it is linked.	The referenced file is used
		   when an open() operation is performed on the link (see
		   open(2)).  A stat() on a symbolic link returns the
		   linked-to file; an lstat() must be performed to obtain
		   information about the link (see stat(2)).  A readlink()
		   call can be used to read the contents of the symbolic
		   link (see readlink(2)).  Symbolic links may span file
		   systems and refer to directories.

    Access Control Lists (ACLs)
      If optional ACL entries are associated with new_file, ln displays a
      plus sign (+) after the access mode when asking permission to

 Hewlett-Packard Company	    - 2 -   HP-UX Release 11i: November 2000

 ln(1)								       ln(1)

      overwrite the file.

      If new_file is a new file, it inherits the access control list of
      file1, altered to reflect any difference in ownership between the two
      files (see acl(5) and aclv(5)).  In JFS file systems, new files
      created by ln do not inherit their parent directory's default ACL
      entries (if any), but instead retain their original ACLs.

    Environment Variables
      LC_CTYPE determines the interpretation of text as single byte and/or
      multibyte characters.

      LANG and LC_CTYPE determine the local language equivalent of y (for
      yes/no queries).

      LANG determines the language in which messages are displayed.

      If LC_CTYPE is not specified in the environment or is set to the empty
      string, the value of LANG is used as a default for each unspecified or
      empty variable.  If LANG is not specified or is set to the empty
      string, a default of C (see lang(5)) is used instead of LANG.  If any
      internationalization variable contains an invalid setting, ln behaves
      as if all internationalization variables are set to C.  See

    International Code Set Support
      Single byte and multibyte character code sets are supported.

      The following command creates file1 and file2 in dest_dir, which are
      linked back to the original files file1 and file2:

	   ln -f file1 file2 dest_dir

      If file1 and/or file2 exists in the destination directory, it is
      removed and replaced by a link to file1 or file2, respectively.  If
      existing file file1 or file2 is a link to another file or a file with
      links, the existing file remains.	 Only the link is broken and
      replaced by a new link to file1 or file2.

      ln does not create hard links across file systems.

      Access control lists of networked files are summarized (as returned in
      st_mode by stat()), but not copied to the new file.  When using ln on
      such files, a + is not printed after the mode value when asking for
      permission to overwrite a file.

 Hewlett-Packard Company	    - 3 -   HP-UX Release 11i: November 2000

 ln(1)								       ln(1)

      ln was developed by AT&T, the University of California, Berkeley and

      cp(1), cpio(1), mv(1), rm(1), link(1M), readlink(2), stat(2),
      symlink(2), symlink(4), acl(5), aclv(5).

      ln: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

 Hewlett-Packard Company	    - 4 -   HP-UX Release 11i: November 2000