Can a file be edited with the ‘write’ permission on it but not on its parent directory

directoryfilespermissions

Suppose the owner/user doesn't have the write permission on a directory but he has it on a file under it. Can the file here be edited or not? If yes, is there any situation where the file cannot be edited?

Best Answer

Yes, the file can be edited.

As far as the directory is concerned, the file can not be edited if you remove the execute permission on the directory for the target (owner/group/others).

EDIT: If you want the owner to not be able to edit the file by changing the permission of the directory (assuming the same user owns the directory and file), then you can simply remove the execute permission on the directory for the owner. For example you can make the permission for the owner as rw- i.e. 6.

Related Question