| 1 |
.\" Copyright 1992, Drew Eckhardt <[email protected]> |
| 2 |
.\" Copyright 1993, Ian Jackson <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH rmdir 2 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
rmdir \- delete a directory |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.B #include <unistd.h> |
| 16 |
.P |
| 17 |
.BI "int rmdir(const char *" path ); |
| 18 |
.fi |
| 19 |
.SH DESCRIPTION |
| 20 |
.BR rmdir () |
| 21 |
deletes a directory, which must be empty. |
| 22 |
.SH RETURN VALUE |
| 23 |
On success, zero is returned. |
| 24 |
On error, \-1 is returned, and |
| 25 |
.I errno |
| 26 |
is set to indicate the error. |
| 27 |
.SH ERRORS |
| 28 |
.TP |
| 29 |
.B EACCES |
| 30 |
Write access to the directory containing |
| 31 |
.I path |
| 32 |
was not allowed, or one of the directories in the path prefix of |
| 33 |
.I path |
| 34 |
did not allow search permission. |
| 35 |
(See also |
| 36 |
.BR path_resolution (7).) |
| 37 |
.TP |
| 38 |
.B EBUSY |
| 39 |
.I path |
| 40 |
is currently in use by the system or some process that prevents its |
| 41 |
removal. |
| 42 |
On Linux, this means |
| 43 |
.I path |
| 44 |
is currently used as a mount point |
| 45 |
or is the root directory of the calling process. |
| 46 |
.TP |
| 47 |
.B EFAULT |
| 48 |
.I path |
| 49 |
points outside your accessible address space. |
| 50 |
.TP |
| 51 |
.B EINVAL |
| 52 |
.I path |
| 53 |
has |
| 54 |
.I . |
| 55 |
as last component. |
| 56 |
.TP |
| 57 |
.B ELOOP |
| 58 |
Too many symbolic links were encountered in resolving |
| 59 |
.IR path . |
| 60 |
.TP |
| 61 |
.B ENAMETOOLONG |
| 62 |
.I path |
| 63 |
was too long. |
| 64 |
.TP |
| 65 |
.B ENOENT |
| 66 |
A directory component in |
| 67 |
.I path |
| 68 |
does not exist or is a dangling symbolic link. |
| 69 |
.TP |
| 70 |
.B ENOMEM |
| 71 |
Insufficient kernel memory was available. |
| 72 |
.TP |
| 73 |
.B ENOTDIR |
| 74 |
.IR path , |
| 75 |
or a component used as a directory in |
| 76 |
.IR path , |
| 77 |
is not, in fact, a directory. |
| 78 |
.TP |
| 79 |
.B ENOTEMPTY |
| 80 |
.I path |
| 81 |
contains entries other than |
| 82 |
.I . |
| 83 |
and |
| 84 |
.IR .. ; |
| 85 |
or, |
| 86 |
.I path |
| 87 |
has |
| 88 |
.I .. |
| 89 |
as its final component. |
| 90 |
POSIX.1 also allows |
| 91 |
.B EEXIST |
| 92 |
for this condition. |
| 93 |
.TP |
| 94 |
.B EPERM |
| 95 |
The directory containing |
| 96 |
.I path |
| 97 |
has the sticky bit |
| 98 |
.RB ( S_ISVTX ) |
| 99 |
set and the process's effective user ID is neither the user ID |
| 100 |
of the file to be deleted nor that of the directory containing it, |
| 101 |
and the process is not privileged (Linux: does not have the |
| 102 |
.B CAP_FOWNER |
| 103 |
capability). |
| 104 |
.TP |
| 105 |
.B EPERM |
| 106 |
The filesystem containing |
| 107 |
.I path |
| 108 |
does not support the removal of directories. |
| 109 |
.TP |
| 110 |
.B EROFS |
| 111 |
.I path |
| 112 |
refers to a directory on a read-only filesystem. |
| 113 |
.SH STANDARDS |
| 114 |
POSIX.1-2024. |
| 115 |
.SH HISTORY |
| 116 |
POSIX.1-2001, SVr4, 4.3BSD. |
| 117 |
.SH BUGS |
| 118 |
Infelicities in the protocol underlying NFS can cause the unexpected |
| 119 |
disappearance of directories which are still being used. |
| 120 |
.SH SEE ALSO |
| 121 |
.BR rm (1), |
| 122 |
.BR rmdir (1), |
| 123 |
.BR chdir (2), |
| 124 |
.BR chmod (2), |
| 125 |
.BR mkdir (2), |
| 126 |
.BR rename (2), |
| 127 |
.BR unlink (2), |
| 128 |
.BR unlinkat (2) |