I tried deleting a folder in my /opt/ file that I had created but got the message

rm: cannot remove '/opt/*': Is a directory

I created this folder, so why am I getting that message?

Thanks again for any help with this!

  • please post the command used
    – ravery
    Sep 23, 2017 at 11:29

1 Answer 1


To delete a directory with rm, you need to add the -d option (if it is empty), or the -r option to delete recursively. Also you can use rmdir to delete empty directories. Check if you have inside some content you want to save to avoid accidental deletion.

  • 1
    sudo may also be required for deleting folder in /opt
    – ravery
    Sep 23, 2017 at 11:36
  • Thanks! Sudo rm -r deleted the folder and the contents of the folder.
    – Berrik
    Sep 23, 2017 at 11:41

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