This advertisement helps me to keep writing articles on this website

Remove a directory in the macOS or Linux terminal

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

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 October 19, 2020. Questions regarding this artice? You can send them to the address below.
By using this site, you acknowledge that you have read and understand our Cookie and Privacy Policy.