2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
4 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\" This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH LN 1 "Oct 25, 2017"
14 ln \- make hard or symbolic links to files
18 \fB/usr/bin/ln\fR [\fB-fs\fR] \fIsource_file\fR [\fItarget\fR]
23 \fB/usr/bin/ln\fR [\fB-fs\fR] \fIsource_file\fR... \fItarget\fR
29 In the first synopsis form, the \fBln\fR utility creates a new directory entry
30 (link) for the file specified by \fIsource_file\fR, at the destination path
31 specified by \fItarget\fR. If \fItarget\fR is not specified, the link is made
32 in the current directory. This first synopsis form is assumed when the final
33 operand does not name an existing directory; if more than two operands are
34 specified and the final is not an existing directory, an error will result.
37 In the second synopsis form, the \fBln\fR utility creates a new directory entry
38 for each file specified by a \fIsource_file\fR operand, at a destination path
39 in the existing directory named by \fItarget\fR.
42 The \fBln\fR utility may be used to create both hard links and symbolic links.
43 A hard link is a pointer to a file and is indistinguishable from the original
44 directory entry. Any changes to a file are effective independent of the name
45 used to reference the file. Hard links may not span file systems and may not
49 \fBln\fR by default creates hard links. \fIsource_file\fR is linked to
50 \fItarget\fR. If \fItarget\fR is a directory, another file named
51 \fIsource_file\fR is created in \fItarget\fR and linked to the original
55 If \fItarget\fR is an existing file and the \fB-f\fR option is not specified,
56 \fBln\fR will write a diagnostic message to standard error, do nothing more
57 with the current \fIsource_file\fR, and go on to any remaining
61 A symbolic link is an indirect pointer to a file; its directory entry contains
62 the name of the file to which it is linked. Symbolic links may span file
63 systems and may refer to directories.
66 File permissions for \fItarget\fR may be different from those displayed with an
67 \fB-l\fR listing of the \fBls\fR(1) command. To display the permissions of
68 \fItarget\fR, use \fBls\fR \fB-lL\fR. See \fBstat\fR(2) for more information.
71 When creating a hard link, and the source file is itself a symbolic link, the
72 target will be a hard link to the file referenced by the symbolic link, not to
73 the symbolic link object itself (\fIsource_file\fR).
77 The following options are supported:
84 Links files without questioning the user, even if the mode of \fItarget\fR
85 forbids writing. This is the default if the standard input is not a terminal.
94 Creates a symbolic link.
96 If the \fB-s\fR option is used with two arguments, \fItarget\fR may be an
97 existing directory or a non-existent file. If \fItarget\fR already exists and
98 is not a directory, an error is returned. \fIsource_file\fR may be any path
99 name and need not exist. If it exists, it may be a file or directory and may
100 reside on a different file system from \fItarget\fR. If \fItarget\fR is an
101 existing directory, a file is created in directory \fItarget\fR whose name is
102 \fIsource_file\fR or the last component of \fIsource_file\fR. This file is a
103 symbolic link that references \fIsource_file\fR. If \fItarget\fR does not
104 exist, a file with name \fItarget\fR is created and it is a symbolic link that
105 references \fIsource_file\fR.
107 If the \fB-s\fR option is used with more than two arguments, \fItarget\fR must
108 be an existing directory or an error will be returned. For each
109 \fIsource_file\fR, a link is created in \fItarget\fR whose name is the last
110 component of \fIsource_file\fR. Each new \fIsource_file\fR is a symbolic link
111 to the original \fIsource_file\fR. The files and \fItarget\fR may reside on
112 different file systems.
118 The following option is supported for \fB/usr/bin/ln\fR only:
125 If \fItarget\fR is an existing file, writes a diagnostic message to stderr and
126 goes on to any remaining \fIsource_file\fRs. The \fB-f\fR option overrides this
127 option. This is the default behavior and is silently ignored.
133 The following operands are supported:
137 \fB\fIsource_file\fR\fR
140 A path name of a file to be linked. This can be either a regular or special
141 file. If the \fB-s\fR option is specified, \fIsource_file\fR can also be a
151 The path name of the new directory entry to be created, or of an existing
152 directory in which the new directory entries are to be created.
158 See \fBlargefile\fR(5) for the description of the behavior of \fBln\fR when
159 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
160 .SH ENVIRONMENT VARIABLES
163 See \fBenviron\fR(5) for descriptions of the following environment variables
164 that affect the execution of \fBln\fR: \fBLANG\fR, \fBLC_ALL\fR,
165 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
169 The following exit values are returned:
176 All the specified files were linked successfully
191 See \fBattributes\fR(5) for descriptions of the following attributes:
200 ATTRIBUTE TYPE ATTRIBUTE VALUE
204 Interface Stability Standard
210 \fBchmod\fR(1), \fBls\fR(1), \fBstat\fR(2), \fBattributes\fR(5),
211 \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5)
215 A symbolic link to a directory behaves differently than you might expect in
216 certain cases. While an \fBls\fR(1) command on such a link displays the files
217 in the pointed-to directory, entering \fBls\fR \fB-l\fR displays information
218 about the link itself:
222 example% \fBln -s dir link\fR
223 example% \fBls link\fR
224 file1 file2 file3 file4
225 example% \fBls -l link\fR
226 lrwxrwxrwx 1 user 7 Jan 11 23:27 link -> dir
233 When you change to a directory (see \fBcd\fR(1)) through a symbolic link, using
234 \fB/usr/bin/sh\fR or \fB/usr/bin/csh\fR, you wind up in the pointed-to location
235 within the file system. This means that the parent of the new working directory
236 is not the parent of the symbolic link, but rather, the parent of the
237 pointed-to directory. This will also happen when using \fBcd\fR with the
238 \fB-P\fR option from \fB/usr/bin/ksh\fR or \fB/usr/bin/sh\fR. For
239 instance, in the following case, the final working directory is \fB/usr\fR and
240 not \fB/home/user/linktest\fR.
246 example% \fBln -s /usr/tmp symlink\fR
247 example% \fBcd symlink\fR
248 example% \fBcd .\|.\fR
257 C shell users can avoid any resulting navigation problems by using the
258 \fBpushd\fR and \fBpopd\fR built-in commands instead of \fBcd\fR.