How can I delete a write only protected folder [closed]
I cannot delete a folder as it says write only protected.Though I am using from root It says that I am not a root user. As I am new in using Ubuntu. Please help me to get rid of this problem.
Solution 1:
From the terminal you can run:
sudo rm -r /my/locked/directory
as the instruction will prompt any warning message during the execution and you will be able to check what are you deleting. Otherwise, if you have checked the warning and are completely sure of files and subfolders contained, you can run:
sudo rm -rf /my/locked/directory
This will remove recursively (-r
) your folder, subfolders and any contents without prompt any warning (-f
) .
If you receive the message: rm: cannot remove '/my/locked/directory': operation not permitted
, then make sure directory (or file) is not protected using extended file system i
attribute.
A file/folder with the i
attribute cannot be modified, it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only root can add or remove i
attribute.
Use lsattr
command to verify that file/folder is not write protected using extended i
attribute - output should be:
----i-------- /my/locked/directory
To remove the i
attribute you can run:
sudo chattr -i /my/locked/directory
then check again with lsattr
. The i
should have been removed. If removed run the sudo rm -r
instructions above.