Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

In bash all I know is that

rmdir directoryname

will remove the directory but only if it's empty. Is there a way to force remove subdirectories?

share|improve this question

1 Answer 1

up vote 54 down vote accepted

The following command will do it for you. Use caution though.

rm -rf directoryname
share|improve this answer
"-f" is "--force" which overrides some sanity checks and prompting. A safer command to start with would be rm -r directoryname. –  Jim Paris Aug 17 '12 at 3:35
For some reason I get a rm: invalid option -- r error when trying to delete a directory with rm -r <directoryname>. –  Sunspawn May 26 at 15:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.