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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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.