How do I delete a directory in Linux terminal?

You can delete a directory in Linux terminal using the rmdir or rm command.

To delete an empty directory, you can use the rmdir command followed by the name of the directory you want to delete:

rmdir directory_name

If the directory is not empty, you can use the rm command with the -r (or --recursive) option to remove the directory and its contents:

rm -r directory_name

Note: Be careful when using the rm command, as it permanently deletes files and directories and does not move them to the trash or recycle bin.

Leave a Comment