To remove a directory, you can use the rm command with the -r (recursive) option. This allows you to delete the directory and all of its contents. Here’s the basic syntax:
rm -r directory-name
For example, to remove a directory named old_projects, you would run:
rm -r old_projects
Important Notes:
- Be very careful with this command, as it will delete everything in the specified directory without asking for confirmation.
- If the directory is empty, you can also use the
rmdircommand:
rmdir directory-name
This command will only work if the directory is empty.
