Linux Command Line Trick: Delete Directory

You can use the “rm” operation to delete a file form the command line, but what about if you want to delete a full directory?

Simply type the following into your command line:

$ rm -fr directory_name 


Here is an example if you also want to try it out in your command line:

# clone this directory

$ git clone

# go into the new CLI-Obstacle-Course directory

$ cd CLI-Obstacle-Course

# locate the directory “delete_me”

$ find . -name delete_me

./delete_me #the delete_me directory is in the current directory

# delete the “delete_me” directory

$ rm -fr delete_me

$ find . -name delete_me

# the directory has been deleted, so nothing is returned

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.