- All right.
Next task is to create the file /tmp/protectedfile,
containing the text, I am protected.
And ensure that this file can be added to, but not removed,
and current contents cannot be changed.
So the solution is obviously in attributes, man chattr.
And what we need is the attribute a for append only.
So let me create /tmp/protectedfile.
And in there, the text, I am protected.
If you see questions like this on the exam,
make sure you don't make any typos
because if they want you to have a text in there,
then really they are going to check for it
and you'll lose points if you have a typo.
So that was easy.
And the other part also is not very complicated.
Chattr +a on /tmp/protectedfile.
Lsattr on /tmp/protectedfile is showing you that this works.
Let's do echo hello >> /tmp/protectedfile, which is working.
Let's use rm -f on /tmp/protectedfile, which is not allowed.
So protectedfiles, append only.
It's a useful attribute.
Not as commonly known as immutable,
but definitely very useful as well.