Section: Linux Programmer's Manual (2)
Return to Main Contents
rmdir - delete a directory
int rmdir(const char *pathname);
deletes a directory, which must be empty.
On success, zero is returned.
On error, -1 is returned, and
is set appropriately.
Write access to the directory containing
was not allowed, or one of the directories in the path prefix of
did not allow search permission.
is currently in use by the system or some process that prevents its
On Linux this means
is currently used as a mount point
or is the root directory of the calling process.
pathname points outside your accessible address space.
as last component.
Too many symbolic links were encountered in resolving
pathname was too long.
A directory component in
does not exist or is a dangling symbolic link.
Insufficient kernel memory was available.
or a component used as a directory in
is not, in fact, a directory.
contains entries other than
. and .. ;
as its final component.
POSIX.1-2001 also allows
for this condition.
The directory containing
has the sticky bit
set and the process's effective user ID is neither the user ID
of the file to be deleted nor that of the directory containing it,
and the process is not privileged (Linux: does not have the
The filesystem containing
does not support the removal of directories.
refers to a directory on a read-only filesystem.
SVr4, 4.3BSD, POSIX.1-2001.
Infelicities in the protocol underlying NFS can cause the unexpected
disappearance of directories which are still being used.
This page is part of release 3.74 of the Linux
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
- RETURN VALUE
- CONFORMING TO
- SEE ALSO