Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

rmdir - remove directories

&pagelevel(4)&pagelevel

rmdir removes one or more empty directories. Directories containing files cannot be removed with rmdir. To remove a directory together with everything it contains you can use the rm command, specifying option -r.


Syntax

rmdir[ -p] directory ...

No option specified

rmdir removes the specified directories.

-p

(p - parents)

The specified directory is removed, and all empty parent directories in the specified path are removed recursively.

directory

Name of the directory you want to remove. You can name any number of directories.

Error

rmdir: dir1: Directory not empty
You have attempted to use rmdir to remove a directory dir1 which still has files in it.
You can use the rm command with option -r to remove directories that contain files.


rmdir: dir1: Directory does not exist
The directory named dir1 does not exist.


rmdir: ../.: Can't remove current directory or ..
rmdir: ../dv1: Can't remove current directory or ..
The current directory or its parent cannot be removed. Change to the parent directory.

Locale

The following environment variables affect the execution of rmdir:

LANG

Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL

If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other.

LC_MESSAGES

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

NLSPATH

Determine the location of message catalogs for the processing of LC_MESSAGES.

Example

Removing the directories pro and proc

Your current directory has the following contents:

drwxr-xr-x  11 SUSAN    other       5720   Nov 18 14:16 ./
drwxr-xr-x  13 ROOT     root        3380   Nov 04 11:48 ../
-rw-------   1 SUSAN    other         79   Jul 19 14:21 .profile
-rwx------   1 SUSAN    other        125   May 25 10:29 begin
drwx------   2 SUSAN    other         32   Oct 11 15:36 pro/
drwx--x--x   2 SUSAN    other         32   Nov 07 10:43 proc/

The directories pro and proc are empty, so you can remove them with rmdir.

$ rmdir pro proc
$ ls -lpa
drwxr-xr-x  11 SUSAN    other       5720   Nov 18 14:16 ./
drwxr-xr-x  13 ROOT     root        3380   Nov 04 11:48 ../
-rw-------   1 SUSAN    other         79   Jul 19 14:21 .profile
-rwx------   1 SUSAN    other        125   May 25 10:29 begin

See also

rm