To remove a directory, you can use the rm command with the -r (recursive) option. Here’s the basic syntax:
rm -r directory_name
Examples:
-
Remove a directory and its contents:
rm -r my_directory -
Force remove a directory without prompts (use with caution):
rm -rf my_directoryThe
-foption forces the removal without asking for confirmation. -
Verify that the directory has been removed:
ls
Important Notes:
- Be very careful when using
rm -r, as it will delete the directory and all its contents permanently. - Always double-check the directory name before executing the command to avoid accidental data loss.
