Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way in Linux on a ext4 file system that I can make a file readable and writeable but not deletable?

The directory that the file resides in still needs to be writeable by the owner of the directory.

share|improve this question
    
What is the use-case? If I can write to a file I can empty it, do you have an application that needs the file to exist even if empty? –  RedGrittyBrick Aug 22 '12 at 17:11
    
Kinda spot on. I want to offer a config file for a user that an app will use but it doesn't matter if its empty. –  Brady Aug 22 '12 at 18:43

1 Answer 1

If you make the directory not writable, the file cannot be deleted.

share|improve this answer
    
The directory still needs to be writeable. I will update question to be more clear –  Brady Aug 22 '12 at 16:06
    
@Brady: Does the directory need to be world-writable? Do you need to prevent the owner of the directory from deleting the file? (This would probably be impossible.) If the answers to both questions are ‘no,’ set the directory mode to 755. –  Scott Oct 1 '12 at 20:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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