Linux Filesystem Cheat Sheet/Remove directory recursively

Delete a directory and all of its contents.

Section: Directory Creation and Removal

Remove directory recursively

bash
bash
rm -rf old-build
Explanation

Powerful and destructive. Verify the path first.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Directory Creation and Removal
Create nested directories
Create a directory path including missing parents.
OpenIn sheetbashsame section
Remove empty directory
Delete a directory only if it is empty.
OpenIn sheetbashsame section
Copy directory recursively with preserved metadata
Copy directory trees while preserving timestamps and mode when possible.
OpenIn sheetbash1 tag match
Show directory tree to a depth
Visualize nested files and directories.
OpenIn sheetbash1 tag match
Move directory
Move a directory to a new location.
OpenIn sheetbash1 tag match
Print working directory
Show the absolute path of the current directory.