rmdir (Remove Directory)
![Deleting Directories with rmdir Command](/_next/image/?url=https%3A%2F%2Fstatic.d-libro.com%2F01-course-content-images%2F2011-10-Linux-Introduction%2F010-main-figures%2Frmdir-remove-directory-id201110020610.webp&w=1920&q=75)
When a directory is empty
You can delete an empty directory using the rmdir
(ReMove DIRectory) command.
For example, to delete an empty directory named dir_a under your working directory, run the command below.
rmdir dir_a
When a directory is not empty
The rmdir
command won't work for a non-empty directory. You need to use the rm
command with the -r
option like in the command below.
rm -r dir_a
The rm
command will be explained later.