symlink(2) System Calls Manual symlink(2) symlink, symlinkat - LIBRARY Standard C library (libc, -lc) #include int symlink(const char *target, const char *linkpath); #include /* AT_* */ #include int symlinkat(const char *target, int newdirfd, const char *linkpath); glibc (. feature_test_macros(7)): symlink(): _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200112L || /* glibc <= 2.19: */ _BSD_SOURCE symlinkat(): glibc 2.10: _POSIX_C_SOURCE >= 200809L glibc 2.10: _ATFILE_SOURCE symlink() linkpath, target. << >>, , . .., ( ) , . ( << >>) , ; (dangling). The permissions of a symbolic link are irrelevant; the ownership is ignored when following the link (except when the protected_symlinks feature is enabled, as explained in proc(5)), but is checked when removal or renaming of the link is requested and the link is in a directory with the sticky bit (S_ISVTX) set. linkpath , . symlinkat() symlinkat() symlink(), , . linkpath , , newdirfd ( , symlink()). linkpath newdirfd AT_FDCWD, linkpath ( symlink()). linkpath , newdirfd . See openat(2) for an explanation of the need for symlinkat(). On success, zero is returned. On error, -1 is returned, and errno is set to indicate the error. EACCES , linkpath, linkpath ( path_resolution(7)). EBADF (symlinkat()) linkpath is relative but newdirfd is neither AT_FDCWD nor a valid file descriptor. EDQUOT . , . EEXIST linkpath . EFAULT target linkpath . EIO -. ELOOP linkpath . ENAMETOOLONG target linkpath. ENOENT linkpath target linkpath . ENOENT (symlinkat()) linkpath is a relative pathname and newdirfd refers to a directory that has been deleted. ENOMEM . ENOSPC , , . ENOTDIR , linkpath, . ENOTDIR (symlinkat()) linkpath is relative and newdirfd is a file descriptor referring to a file other than a directory. EPERM , linkpath, . EROFS linkpath , . POSIX.1-2008. symlink() SVr4, 4.3BSD, POSIX.1-2001. symlinkat() POSIX.1-2008. Linux 2.6.16, glibc 2.4. glibc , symlinkat() , glibc symlink(). linkpath , glibc /proc/self/fd, newdirfd. target. , , ( ). , link(2). . ln(1), namei(1), lchown(2), link(2), lstat(2), open(2), readlink(2), rename(2), unlink(2), path_resolution(7), symlink(7) Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . symlink(2)