As root run:
cd /tmp
seq 10 > foo
chmod 666 foo
seq 10 >> foo
chown daemon foo
seq 10 >> foo
This gives:
-bash: foo: Permission denied
It is clear that it is due to /tmp
's special permission (drwxrwxrwt), because it works fine in /tmp/bardir
.
But why? Should the group ownership and permission not allow root
to append to the file?
$ ls -l foo
-rw-rw-rw- 1 daemon root 42 Dec 6 09:11 foo
$ lsattr foo
-------------------- foo
$ ls -ld /tmp
drwxrwxrwt 34 root root 137 Dec 6 09:11 /tmp
$ lsattr -d /tmp
-------------------- /tmp