I added the append-only attribute to a text file.

But I get operation not permitted when I try to use Geany to edit it.

But I can use echo new >> test.txt and it does append.

What am I not understanding?

  • Please tell us what you are doing. – pLumo Sep 3 '18 at 14:57
  • Who knows from what little you posted. You need to post more details. – Panther Sep 3 '18 at 14:57
  • Edited my post. @Panther – fixit7 Sep 3 '18 at 15:00
  • I added append only attribute to a text file. I simply want to edit it using Geany. @RoVo – fixit7 Sep 3 '18 at 15:01
  • 1
    > overwrites the file. You need >> echo new >> test.txt – Panther Sep 3 '18 at 15:03

So you set the append-only attribute on a file with:

chattr +a test.txt

And editing it on a text editor such as Geany doesn't work...

That's somewhat expected, since text editors will not save their buffers to a file by appending to the file, instead they'll rewrite the file when done editing.

While technically possible for a text editor to support editing append-only files, that's not really trivial to implement, since first they'd have to detect this specifically (using the equivalent of the lsattr command) and then work on a mode that would be compatible with that setting, keeping track of how much was in the original file, then preventing modifications to those lines while editing the file and also implementing a separate routine to save an append-only file, which would open the file for appending and only write the lines added in this edit session.

This is quite a niche use case for a text editor, so I don't really know of any text editors which have implementing this, even though it would be technically possible...

The append-only attribute is meant not really as a flag to be consumed by applications (in other words, normal programs are typically not expected to query whether a file has that attribute set), but instead as a safety measure to prevent mistakes from destroying important data.

For example, this attribute makes a lot of sense in log files, where a syslog application should only append to the file and never overwrite or truncate it. Setting this flag is useful in case a syslog application (or other program manipulating log files) has bugs or is misconfigured and would trigger an action that would clobber the file. In that case, the attribute prevents the program from destroying important data, instead simply returning an error to the misbehaving program.

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.