Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

rmdir

The rmdir is used to delete a directory. It does the opposite of the mkdir command.

Deleting a folder

To delete a folder, use:

rmdir folder_name

If the folder is empty then it would be deleted, otherwise you'd get an error similar to rmdir: folder_name: Directory not empty.

To circumvent this, pass an -r flag which stands for recursive, and use rm instead of rmdir. This would delete the directory and it's content.

rm -r folder_name

Deleting multiple folders

To delete multiple folders at once, use rm -r followed by all the folder names.

{{#tabs }} {{#tab name="Unix" }}

rm -r first_folder second_folder third_folder

{{#endtab }}

{{#tab name="Powershell" }}

rm -r first_folder, second_folder, third_folder

{{#endtab }}

{{#tab name="Linux/WSL" }}

rm -r first_folder second_folder third_folder

{{#endtab }} {{#endtabs }}

warning

The -r flag deletes a folder and everything inside it. Use it carefully — deleted files cannot be easily recovered.