How can you delete a folder on macOS or Linux with a terminal command?

Remove a directory in the macOS or Linux terminal.

Remove folder recursively, force

Remove folder and all contents (also subfolders) and never prompt.

rm -rf testfolder

Remove folder recursively

Remove folder and all contents (also subfolders). Command might prompt before removing.

rm -r testfolder

Remove empty folder

Remove folder if it is empty.

rm testfolder

Meaning of the parameters

parameter description
r Recursive
f Force
Written by Loek van den Ouweland on 2020-10-19.
Questions regarding this artice? You can send them to the address below.