smbclient deltree with read-only directories

I’m trying to delete files on a NetApp server using smbclient //servername/share -c "deltree directory_to_delete". It works except for folders which have the read-only flag set. In this case, the command aborts with NT_STATUS_CANNOT_DELETE.

I can view the flags with smbclient //servername/share -c "ls directory_to_delete/*" and remove them with smbclient //servername/share -c "setmode directory_to_delete/subdir_with_ro_flag -r", but only per directory.

Is there a way to automate this (remove the read-only flag recursively) or any other way how to recursively delete a directory with read-only subdirectories?

Btw. the Windows explorer does not complain when deleting such directories (using the same credentials). I’m sure it removes the ro-flag silently.

Asked By: Schorschii


The solution for NetApp is to enable the option cifs.perm_check_ro_del_ok.

options cifs.perm_check_ro_del_ok on


Btw. the read-only flag on directories has a complete other meaning than one would expect, see here.

Answered By: Schorschii
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.