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 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" Modified 1993-07-24 by Rik Faith
8 .\" Modified 1996-04-26 by Nick Duffek <nsd@bbc.com>
9 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
10 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
11 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
13 .TH SYMLINK 2 2022-09-09 "Linux man-pages (unreleased)"
15 symlink, symlinkat \- make a new name for a file
18 .RI ( libc ", " \-lc )
21 .B #include <unistd.h>
23 .BI "int symlink(const char *" target ", const char *" linkpath );
25 .BR "#include <fcntl.h> " "/* Definition of " AT_* " constants */"
26 .B #include <unistd.h>
28 .BI "int symlinkat(const char *" target ", int " newdirfd \
29 ", const char *" linkpath );
33 Feature Test Macro Requirements for glibc (see
34 .BR feature_test_macros (7)):
39 _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L
40 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
41 || /* Glibc <= 2.19: */ _BSD_SOURCE
47 _POSIX_C_SOURCE >= 200809L
53 creates a symbolic link named
55 which contains the string
58 Symbolic links are interpreted at run time as if the contents of the
59 link had been substituted into the path being followed to find a file or
62 Symbolic links may contain
64 path components, which (if used at the start of the link) refer to the
65 parent directories of that in which the link resides.
67 A symbolic link (also known as a soft link) may point to an existing
68 file or to a nonexistent one; the latter case is known as a dangling
71 The permissions of a symbolic link are irrelevant; the ownership is
72 ignored when following the link
75 feature in enabled, as explained in
77 but is checked when removal or
78 renaming of the link is requested and the link is in a directory with
91 system call operates in exactly the same way as
93 except for the differences described here.
95 If the pathname given in
97 is relative, then it is interpreted relative to the directory
98 referred to by the file descriptor
100 (rather than relative to the current working directory of
101 the calling process, as is done by
103 for a relative pathname).
113 is interpreted relative to the current working
114 directory of the calling process (like
125 for an explanation of the need for
128 On success, zero is returned.
129 On error, \-1 is returned, and
131 is set to indicate the error.
135 Write access to the directory containing
137 is denied, or one of the directories in the path prefix of
139 did not allow search permission.
141 .BR path_resolution (7).)
150 nor a valid file descriptor.
153 The user's quota of resources on the filesystem has been exhausted.
154 The resources could be inodes or disk blocks, depending on the filesystem
162 .IR target " or " linkpath " points outside your accessible address space."
165 An I/O error occurred.
168 Too many symbolic links were encountered in resolving
172 .IR target " or " linkpath " was too long."
175 A directory component in
177 does not exist or is a dangling symbolic link, or
186 is a relative pathname and
188 refers to a directory that has been deleted.
191 Insufficient kernel memory was available.
194 The device containing the file has no room for the new directory
198 A component used as a directory in
200 is not, in fact, a directory.
207 is a file descriptor referring to a file other than a directory.
210 The filesystem containing
212 does not support the creation of symbolic links.
216 is on a read-only filesystem.
219 was added to Linux in kernel 2.6.16;
220 library support was added to glibc in version 2.4.
223 SVr4, 4.3BSD, POSIX.1-2001, POSIX.1-2008.
224 .\" SVr4 documents additional error codes EDQUOT and ENOSYS.
227 .\" re multiple files with the same name, and NFS.
236 Deleting the name referred to by a symbolic link will actually delete the
237 file (unless it also has other hard links).
238 If this behavior is not desired, use
241 On older kernels where
243 is unavailable, the glibc wrapper function falls back to the use of
247 is a relative pathname,
248 glibc constructs a pathname based on the symbolic link in
250 that corresponds to the
263 .BR path_resolution (7),