1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\" and Copyright (C) 1993 Michael Haardt, Ian Jackson.
3 .\" and Copyright (C) 2006, 2014 Michael Kerrisk
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .\" Modified 1993-07-24 by Rik Faith
28 .\" Modified 1996-04-26 by Nick Duffek <nsd@bbc.com>
29 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
33 .TH SYMLINK 2 2017-09-15 "Linux" "Linux Programmer's Manual"
35 symlink, symlinkat \- make a new name for a file
38 .B #include <unistd.h>
40 .BI "int symlink(const char *" target ", const char *" linkpath );
42 .BR "#include <fcntl.h> " "/* Definition of AT_* constants */"
43 .B #include <unistd.h>
45 .BI "int symlinkat(const char *" target ", int " newdirfd \
46 ", const char *" linkpath );
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
57 _XOPEN_SOURCE\ >=\ 500 || _POSIX_C_SOURCE\ >=\ 200112L
58 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
59 || /* Glibc versions <= 2.19: */ _BSD_SOURCE
68 _POSIX_C_SOURCE\ >=\ 200809L
77 creates a symbolic link named
79 which contains the string
82 Symbolic links are interpreted at run time as if the contents of the
83 link had been substituted into the path being followed to find a file or
86 Symbolic links may contain
88 path components, which (if used at the start of the link) refer to the
89 parent directories of that in which the link resides.
91 A symbolic link (also known as a soft link) may point to an existing
92 file or to a nonexistent one; the latter case is known as a dangling
95 The permissions of a symbolic link are irrelevant; the ownership is
96 ignored when following the link, but is checked when removal or
97 renaming of the link is requested and the link is in a directory with
110 system call operates in exactly the same way as
112 except for the differences described here.
114 If the pathname given in
116 is relative, then it is interpreted relative to the directory
117 referred to by the file descriptor
119 (rather than relative to the current working directory of
120 the calling process, as is done by
122 for a relative pathname).
132 is interpreted relative to the current working
133 directory of the calling process (like
142 On success, zero is returned.
143 On error, \-1 is returned, and
145 is set appropriately.
149 Write access to the directory containing
151 is denied, or one of the directories in the path prefix of
153 did not allow search permission.
155 .BR path_resolution (7).)
158 The user's quota of resources on the filesystem has been exhausted.
159 The resources could be inodes or disk blocks, depending on the filesystem
167 .IR target " or " linkpath " points outside your accessible address space."
170 An I/O error occurred.
173 Too many symbolic links were encountered in resolving
177 .IR target " or " linkpath " was too long."
180 A directory component in
182 does not exist or is a dangling symbolic link, or
189 Insufficient kernel memory was available.
192 The device containing the file has no room for the new directory
196 A component used as a directory in
198 is not, in fact, a directory.
201 The filesystem containing
203 does not support the creation of symbolic links.
207 is on a read-only filesystem.
209 The following additional errors can occur for
214 is not a valid file descriptor.
218 is a relative pathname and
220 refers to a directory that has been deleted.
226 is a file descriptor referring to a file other than a directory.
229 was added to Linux in kernel 2.6.16;
230 library support was added to glibc in version 2.4.
233 SVr4, 4.3BSD, POSIX.1-2001, POSIX.1-2008.
234 .\" SVr4 documents additional error codes EDQUOT and ENOSYS.
237 .\" re multiple files with the same name, and NFS.
246 Deleting the name referred to by a symbolic link will actually delete the
247 file (unless it also has other hard links).
248 If this behavior is not desired, use
251 On older kernels where
253 is unavailable, the glibc wrapper function falls back to the use of
257 is a relative pathname,
258 glibc constructs a pathname based on the symbolic link in
260 that corresponds to the
273 .BR path_resolution (7),