To remove/delete directories (folders), we can use the rm command and the rmdir command.
rmdir
a command-line utility for deleting empty directoriesrm
remove directories and their contents recursively
In this tutorial, we will show you how to use the rm and rmdir commands to remove directories in Linux/Unix.
Use rmdir or rm -d to delete an empty directory, followed by the name of the directory
➜ rmdir emptyDir
➜ rm -d emptyDir
Use the rm command -r option to recursively delete a non-empty directory and all files in it
➜ rm -r nonEmptyDir
Use the rm -r command to delete multiple directories at once, separated by spaces
➜ rm -r nonEmptyDir1 nonEmptyDir2 nonEmptyDir3
Use the rm -r command and bracket expansion to delete multiple directories at once
➜ rm -r {a..c}_dir
Use the rm -rf command to force delete the non-empty directory without prompt
➜ rm -rf nonEmptyDir