1RMDIR(2)                   Linux Programmer's Manual                  RMDIR(2)
2
3
4

NAME

6       rmdir - delete a directory
7

SYNOPSIS

9       #include <unistd.h>
10
11       int rmdir(const char *pathname);
12

DESCRIPTION

14       rmdir() deletes a directory, which must be empty.
15

RETURN VALUE

17       On  success,  zero is returned.  On error, -1 is returned, and errno is
18       set to indicate the error.
19

ERRORS

21       EACCES Write access to the directory containing pathname  was  not  al‐
22              lowed,  or one of the directories in the path prefix of pathname
23              did not allow search permission.  (See also path_resolution(7).)
24
25       EBUSY  pathname is currently in use by the system or some process  that
26              prevents  its  removal.   On  Linux, this means pathname is cur‐
27              rently used as a mount point or is the  root  directory  of  the
28              calling process.
29
30       EFAULT pathname points outside your accessible address space.
31
32       EINVAL pathname has .  as last component.
33
34       ELOOP  Too many symbolic links were encountered in resolving pathname.
35
36       ENAMETOOLONG
37              pathname was too long.
38
39       ENOENT A  directory  component  in pathname does not exist or is a dan‐
40              gling symbolic link.
41
42       ENOMEM Insufficient kernel memory was available.
43
44       ENOTDIR
45              pathname, or a component used as a  directory  in  pathname,  is
46              not, in fact, a directory.
47
48       ENOTEMPTY
49              pathname contains entries other than . and .. ; or, pathname has
50              ..  as its final component.  POSIX.1 also allows EEXIST for this
51              condition.
52
53       EPERM  The  directory  containing pathname has the sticky bit (S_ISVTX)
54              set and the process's effective user ID is neither the  user  ID
55              of  the  file to be deleted nor that of the directory containing
56              it, and the process is not privileged (Linux: does not have  the
57              CAP_FOWNER capability).
58
59       EPERM  The  filesystem containing pathname does not support the removal
60              of directories.
61
62       EROFS  pathname refers to a directory on a read-only filesystem.
63

CONFORMING TO

65       POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
66

BUGS

68       Infelicities in the protocol underlying NFS can  cause  the  unexpected
69       disappearance of directories which are still being used.
70

SEE ALSO

72       rm(1),  rmdir(1),  chdir(2),  chmod(2), mkdir(2), rename(2), unlink(2),
73       unlinkat(2)
74

COLOPHON

76       This page is part of release 5.13 of the Linux  man-pages  project.   A
77       description  of  the project, information about reporting bugs, and the
78       latest    version    of    this    page,    can     be     found     at
79       https://www.kernel.org/doc/man-pages/.
80
81
82
83Linux                             2021-03-22                          RMDIR(2)
Impressum