I was struggling with file permission of Magento 2 in Mac’s MAMP. Finally got the solution. If I use _www I need sudo command for magento CLI which I did not want. otherwise every time I had to set 777 when delete all the temp files.
so I set permission for user and group. It works:
sudo chown -R _www:staff var/ pub/
Even Better solution that will work perfectly is here:
change the apache user and group same as Mac User and Group:
on /etc/apaache2/httpd.conf (or this file can be different location according to your apache installation)
sudo vi /etc/apache2/httpd.conf
find the User and Group, normally it is _www and _www. change it to:
User YOUR-MAC-USER Group staff
from next time there should not be any permission problem.