Creating files in /tmp changes default group ownership? We are supposed to stop using /tmp

filesystem

I just noticed:

~$ touch ~/home.txt
~$ touch /tmp/tmp.txt
~$ ls -l ~/home.txt
-rw-r–r– 1 jdough staff 0 Dec 2 15:09 /Users/jdough/home.txt
~$ ls -l /tmp/tmp.txt
-rw-r–r– 1 jdough wheel 0 Dec 2 15:09 /tmp/tmp.txt

Is it unusual that OS X uses the file system to decide the group ownership? I'd expected all files created by a user to have staff as the group.

I've been tarring cds in /tmp and then putting them in cloud storage. Isn't that a classic use case for /tmp? As users, are we supposed to stop using /tmp? I don't want my group ownership messed with and tmp is now wired to unexpectedly change the group.

Of course, just using $HOME/tmp is fine. But, I'll be sad to stop using /tmp.

Best Answer

I had the same experience when using /tmp but using $TMPDIR worked as expected:

$ touch "${TMPDIR}/tmp.txt"
$ ls -l "${TMPDIR}/tmp.txt"

-rw-r--r-- 1 luomat staff 0 Dec  3 08:46    /var/folders/8k/0bqq33mn439938qxp7j7c1fc0000gn/T//tmp.txt