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
--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
rmdir mydir1 mydir2 mydir3 .....Removes multiple directories using the basic rmdir command.
rmdir LINUX INFO DETAILRemoves the LINUX, INFO, and DETAIL directories.
rmdir -p mydir1/mydir2/mydir3/...../mydirNDeletes a directory, including all subdirectories.
rmdir -p LINUX/mydir1/mydir2/mydir3Deletes the LINUX directory, including all its ancestors.
rmdir -p -v Example/TestRemoves a subdirectory and its hierarchical parent and lists each step of the process.
rmdir -v dir1 dir2 dir3Displays a message after removing the specified directories.
rmdir -v LINUX INFO DETAILDeletes the LINUX, INFO, and DETAIL directories and displays a message after each removal.
rmdir -v LINUX*Deletes all directories that contain "LINUX" in their name and displays a message after each removal.
rmdir -v Example/Test ExampleRemoves multiple directories in reverse order of hierarchy and lists each step of the process.
rmdir -v Example*Removes multiple directories with similar names using wildcards and lists each step of the process.
rmdir --ignore-fail-on-non-empty LINUXIgnores errors due to non-empty directories when attempting to remove the LINUX directory.
Last updated
Was this helpful?