My /tmp directory became unwritable yesterday, I believe that the permissions are all set correctly:
$ ls -l /
lrwxr-xr-x@ 1 root wheel 11 Sep 22 16:05 tmp -> private/tmp
$ ls -l /private
drwxrwxrwt@ 3 root wheel 102 Oct 17 15:04 tmp
$ ls -leO@d /private/tmp
drwxrwxrwt@ 3 root wheel restricted 102 Oct 17 15:04 /private/tmp
com.apple.rootless 0
However, I get an error when I attempt to write into this directory, even with sudo:
$ cd /tmp
$ pwd
/tmp
$ sudo cat > test
-bash: test: Operation not permitted
I'm using OS X El Capitan 10.11.6. Any help is much appreciated- thanks!
Edit: after following fd0's suggestion, it looks like the directory might be rootless, which I suppose is related to SIP and may be why root cannot make changes. I note that the contents that I see in the /tmp directory appear to be related to App Store automatic download to be used to upgrade my Mac to Sierra if I request it in the future: perhaps something broke during this App Store process? I'm still not sure how to correct my system, though.
Edit2: I solved this problem by upgrading to Sierra. Probably the steps linked to by Slava below would mostly work but it sounds like the extended attributes would be lost so I chose to upgrade instead.
ls -leO@d /private/tmp