rmdir

rmdir linux command cheatsheet by Thamizhiniyan C S

Introduction

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


Syntax

rmdir [OPTION]... DIRECTORY...


Important Flags

FlagDescription

--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

CommandDescription

Removes multiple directories using the basic rmdir command.

Removes the LINUX, INFO, and DETAIL directories.

Deletes a directory, including all subdirectories.

Deletes the LINUX directory, including all its ancestors.

Removes a subdirectory and its hierarchical parent and lists each step of the process.

Displays a message after removing the specified directories.

Deletes the LINUX, INFO, and DETAIL directories and displays a message after each removal.

Deletes all directories that contain "LINUX" in their name and displays a message after each removal.

Removes multiple directories in reverse order of hierarchy and lists each step of the process.

Removes multiple directories with similar names using wildcards and lists each step of the process.

Ignores errors due to non-empty directories when attempting to remove the LINUX directory.

Last updated