Linux Rm A Folder And Contents

Posted on in Categories , , , , , , last updated May 23, 2010

How do I remove a folder and all its contents including files and other folders?

You need to use the rm command. Use the -r option to remove the listed directories and their contents recursively. The syntax is:

rm -rf dirName

In this example, remove data directory and their contents recursively, enter:

rm -rf data

See also:

See the rm command man page for more information:
man rm

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

1 comment

Leave a Comment