I have CentOS and cPanel installed. I want to lock certain files (e.g. .ftpquota) from being deleted through FTP. I tried to change the ownership to root:root or root:lock but it didn't work; neither did changing the mode to 0.

How can I lock the .ftpquota file?


If you don't need to modify the file then the chattr +i will lock the file from deletion. This will mark the file immutable.

Otherwise file deletion is controlled by the directory containing the file. Anyone with write access to the directory can delete most of the files it contains. Files with the sticky bit set can only be deleted by the owner. Files with the immutable attribute can not be deleted until the attribute is removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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