> For the complete documentation index, see [llms.txt](https://thamizhiniyancs.gitbook.io/cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thamizhiniyancs.gitbook.io/cheatsheets/linux/manipulating-files-directories/rmdir.md).

# rmdir

## Introduction

This command is used to remove the DIRECTORY(ies), if they are empty.

***

## Syntax

`rmdir [OPTION]... DIRECTORY...`

***

## Important Flags

| Flag                         | Description                                                                |
| ---------------------------- | -------------------------------------------------------------------------- |
| `--ignore-fail-on-non-empty` | Doesn't show an error message when trying to remove a non-empty directory. |
| `-p`                         | Removes the directory along with its parent in the hierarchy.              |
| `-v`                         | Provides a verbose output.                                                 |
| `--help`                     | Displays help text.                                                        |
| `--version`                  | Displays the command version.                                              |

***

## Examples

<table><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir mydir1 mydir2 mydir3 .....
</code></pre></td><td>Removes multiple directories using the basic rmdir command.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir LINUX INFO DETAIL
</code></pre></td><td>Removes the LINUX, INFO, and DETAIL directories.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -p mydir1/mydir2/mydir3/...../mydirN
</code></pre></td><td>Deletes a directory, including all subdirectories.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -p LINUX/mydir1/mydir2/mydir3
</code></pre></td><td>Deletes the LINUX directory, including all its ancestors.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -p -v Example/Test
</code></pre></td><td>Removes a subdirectory and its hierarchical parent and lists each step of the process.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -v dir1 dir2 dir3
</code></pre></td><td>Displays a message after removing the specified directories.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -v LINUX INFO DETAIL
</code></pre></td><td>Deletes the LINUX, INFO, and DETAIL directories and displays a message after each removal.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -v LINUX*
</code></pre></td><td>Deletes all directories that contain "LINUX" in their name and displays a message after each removal.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -v Example/Test Example
</code></pre></td><td>Removes multiple directories in reverse order of hierarchy and lists each step of the process.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir -v Example*
</code></pre></td><td>Removes multiple directories with similar names using wildcards and lists each step of the process.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">rmdir --ignore-fail-on-non-empty LINUX
</code></pre></td><td>Ignores errors due to non-empty directories when attempting to remove the LINUX directory.</td></tr></tbody></table>
