1rmdir(2) System Calls Manual rmdir(2)
2
3
4
6 rmdir - delete a directory
7
9 Standard C library (libc, -lc)
10
12 #include <unistd.h>
13
14 int rmdir(const char *pathname);
15
17 rmdir() deletes a directory, which must be empty.
18
20 On success, zero is returned. On error, -1 is returned, and errno is
21 set to indicate the error.
22
24 EACCES Write access to the directory containing pathname was not al‐
25 lowed, or one of the directories in the path prefix of pathname
26 did not allow search permission. (See also path_resolution(7).)
27
28 EBUSY pathname is currently in use by the system or some process that
29 prevents its removal. On Linux, this means pathname is cur‐
30 rently used as a mount point or is the root directory of the
31 calling process.
32
33 EFAULT pathname points outside your accessible address space.
34
35 EINVAL pathname has . as last component.
36
37 ELOOP Too many symbolic links were encountered in resolving pathname.
38
39 ENAMETOOLONG
40 pathname was too long.
41
42 ENOENT A directory component in pathname does not exist or is a dan‐
43 gling symbolic link.
44
45 ENOMEM Insufficient kernel memory was available.
46
47 ENOTDIR
48 pathname, or a component used as a directory in pathname, is
49 not, in fact, a directory.
50
51 ENOTEMPTY
52 pathname contains entries other than . and .. ; or, pathname has
53 .. as its final component. POSIX.1 also allows EEXIST for this
54 condition.
55
56 EPERM The directory containing pathname has the sticky bit (S_ISVTX)
57 set and the process's effective user ID is neither the user ID
58 of the file to be deleted nor that of the directory containing
59 it, and the process is not privileged (Linux: does not have the
60 CAP_FOWNER capability).
61
62 EPERM The filesystem containing pathname does not support the removal
63 of directories.
64
65 EROFS pathname refers to a directory on a read-only filesystem.
66
68 POSIX.1-2008.
69
71 POSIX.1-2001, SVr4, 4.3BSD.
72
74 Infelicities in the protocol underlying NFS can cause the unexpected
75 disappearance of directories which are still being used.
76
78 rm(1), rmdir(1), chdir(2), chmod(2), mkdir(2), rename(2), unlink(2),
79 unlinkat(2)
80
81
82
83Linux man-pages 6.05 2023-03-30 rmdir(2)