I don't know about homebrew
in particular, but in theory you could use sudo
to install software. Then files are accessed with root
privileges, which may or may not be what you want.
In general though, if you want multiple unprivileged users to be able to write to the same location, it isn't the owner of that location that you want to change, but its group. You could create a group called homebrewers
:
sudo dscl . -create /Groups/homebrewers
You'll then want to find a group ID that doesn't exist. For this I used:
dscl . -list /Groups \
| sed 's@^@/Groups/@' \
| ( while read grp; \
do dscl . -read "${grp}" PrimaryGroupID; \
done ) \
| sort -snk 2
I found that the highest group number in use was 501, so 4200 was available.
So, I set the PrimaryGroupID
to 4200
and the Password
to *
(unused). Do not forget to set these! If you do, your groups list will be corrupted and you will likely have to boot into single-user mode to correct it.
sudo dscl . -append /Groups/homebrewers PrimaryGroupID 4200
sudo dscl . -append /Groups/homebrewers Password '*'
Then add your two users to that group. The example here uses shortnames (from whoami
) of user1
and user2
:
sudo dscl . -append /Groups/homebrewers GroupMembership user1
sudo dscl . -append /Groups/homebrewers GroupMembership user2
Note that you may have to log out and log back in for these changes to take effect.
Finally, you'll want to change the directory's group to be homebrewers
and its permissions to be group-writable:
chown -R :homebrewers /usr/local/var/homebrew
chmod -R g+w /usr/local/var/homebrew
If you want, you can even change the owner to root
to no ill effects:
sudo chown -R root /usr/local/var/homebrew
All commands shown here were tested on Mac OS X 10.4.11 on a PowerBook G4. Much has changed since the move to Intel, so the commands as shown may not work exactly as given on a newer release. The underlying concepts will remain the same.