1 .\" This manpage is Copyright (C) 1992 Drew Eckhardt;
2 .\" and Copyright (C) 1993 Ian Jackson.
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1996-09-08 by Arnt Gulbrandsen <agulbra@troll.no>
28 .\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
29 .\" Modified 2001-05-17 by aeb
30 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
32 .TH UNLINK 2 2011-09-15 "Linux" "Linux Programmer's Manual"
34 unlink \- delete a name and possibly the file it refers to
36 .B #include <unistd.h>
38 .BI "int unlink(const char *" pathname );
41 deletes a name from the file system.
43 last link to a file and no processes have the file open the file is
44 deleted and the space it was using is made available for reuse.
46 If the name was the last link to a file but any processes still have
47 the file open the file will remain in existence until the last file
48 descriptor referring to it is closed.
50 If the name referred to a symbolic link the link is removed.
52 If the name referred to a socket, fifo or device the name for it is
53 removed but processes which have the object open may continue to use
56 On success, zero is returned.
57 On error, \-1 is returned, and
63 Write access to the directory containing
65 is not allowed for the process's effective UID, or one of the
68 did not allow search permission.
70 .BR path_resolution (7).)
75 cannot be unlinked because it is being used by the system
77 for example, it is a mount point
78 or the NFS client software created it to represent an
79 active but otherwise nameless inode ("NFS silly renamed").
83 points outside your accessible address space.
86 An I/O error occurred.
90 refers to a directory.
91 (This is the non-POSIX value returned by Linux since 2.1.132.)
94 Too many symbolic links were encountered in translating
98 .IR pathname " was too long."
103 does not exist or is a dangling symbolic link, or
108 Insufficient kernel memory was available.
111 A component used as a directory in
113 is not, in fact, a directory.
116 The system does not allow unlinking of directories,
117 or unlinking of directories requires privileges that the
118 calling process doesn't have.
119 (This is the POSIX prescribed error return;
120 as noted above, Linux returns
124 .BR EPERM " (Linux only)"
125 The file system does not allow unlinking of files.
127 .BR EPERM " or " EACCES
128 The directory containing
132 set and the process's effective UID is neither the UID of the file to
133 be deleted nor that of the directory containing it, and
134 the process is not privileged (Linux: does not have the
140 refers to a file on a read-only file system.
142 SVr4, 4.3BSD, POSIX.1-2001.
143 .\" SVr4 documents additional error
144 .\" conditions EINTR, EMULTIHOP, ETXTBSY, ENOLINK.
146 Infelicities in the protocol underlying NFS can cause the unexpected
147 disappearance of files which are still being used.
159 .BR path_resolution (7),