Use rmdir to remove an empty directory or rm to remove a directory and its contents. These commands delete directly rather than moving items to a desktop waste bin.

Check the target directory

Before deleting anything, confirm your current location and inspect the directory. Replace directory_name with the intended directory name:

pwd
ls -la -- "./directory_name"

The ./ prefix identifies a directory relative to your current location. Keep names containing spaces in quotes. Make a backup of any contents you need to retain.

Remove an empty directory

Run:

rmdir -- "./directory_name"

This fails if the directory contains files or subdirectories, including hidden entries. On GNU systems, rm -d is another option for an empty directory:

rm -d -- "./directory_name"

Remove a directory and its contents

For interactive deletion, use recursive removal with confirmation prompts:

rm -ri -- "./directory_name"

The -r option includes the directory’s contents and subdirectories; -i asks before removal. Read each prompt before answering.

The non-interactive form rm -r also removes a directory tree, but it does not request confirmation for every item. Use it only after checking the target and contents.

Understand removal options

OptionEffect
rm -dRemoves an empty directory on GNU systems.
rm -rRemoves a directory and its contents recursively.
rm -iPrompts before each removal.
rm -fIgnores missing targets and suppresses prompts. It does not make deletion recoverable.
rmdir -pAlso removes parent directories if they become empty.
rmdir -vReports each directory removed.

Do not use broad wildcard patterns or add -f simply to bypass an error. Check the path, permissions and contents first.