How to use HomeBrew on a Multi-user Mac environment

Akshay Kumar
Mac O’Clock
Published in
3 min readMay 2, 2020

--

Photo by Domenico Loia on Unsplash

If you are Admin user or Standard user then you can set it very easily by using few commands:

Setup —
1. check what is your user's group name — in mac most of it is staff gruop name but we can verify using this command —

check group name using the command id -gn it will give the user group name. where id will give all information about user name, user id, group name, and group id, type id -un it will return user name also.

Let’s group name is staff . Then allows group members to write inside this directory. First, check the healthiness of brew.

akshay$ brew doctorYour system is raring to brew. it will show any issue in brew

check default installation brew directory and group name

akshay$ echo $(brew --prefix)
/usr/local
akshay$ id -gn
staff

add a staff group name in the user directory, Note — replace staff to your user group name in every command.

akshay$ sudo dseditgroup -o edit -a $(whoami) -t user staff

Change the group of the homebrew installation directory

akshay$ sudo chgrp -R staff $(brew --prefix)/*

Allow group members to write inside this directory

akshay$ sudo chmod -R g+rwX $(brew --prefix)/*

Now check group is added in /user/local directory

akshay$ ls -la $(brew --prefix)
drwxrwxrwx 3 akshay staff 96 Apr 19 03:12 Caskroom
drwxrwxrwx 28 akshay staff 896 Apr 23 01:52 Cellar
drwxrwxrwx 3 akshay staff 96 Apr 19 02:37 Frameworks
drwxrwxrwx 20 akshay staff 640 Apr 23 01:51 Homebrew
drwxrwxrwx 159 akshay staff 5088 Apr 22 10:00 bin
drwxrwxrwx 11 akshay staff 352 Jan 24 21:45 etc
drwxrwxrwx 46 akshay staff 1472 Apr 23 01:52 include
drwxrwxrwx 100 akshay staff 3200 Apr 22 10:00 lib
drwxrwxrwx 42 akshay staff 1344 Apr 23 01:52 opt
drwxrwxrwx 14 akshay staff 448 Apr 23 01:52 sbin
drwxrwxrwx 17 akshay staff 544 Apr 19 02:37 share
drwxrwxrwx 10 akshay staff 320 Feb 1 18:31 var

All commands in a single snip (Please use your group name in place of staff)

akshay$ brew doctor
akshay$ echo $(brew --prefix)
/usr/local
akshay$ id -gn
staff
akshay$ sudo dseditgroup -o edit -a $(whoami) -t user staff
akshay$ sudo chgrp -R staff $(brew --prefix)/*
akshay$ sudo chmod -R g+rwX $(brew --prefix)/*
akshay$ ls -la $(brew --prefix)
drwxrwxrwx 3 akshay staff 96 Apr 19 03:12 Caskroom
drwxrwxrwx 28 akshay staff 896 Apr 23 01:52 Cellar
drwxrwxrwx 3 akshay staff 96 Apr 19 02:37 Frameworks
drwxrwxrwx 20 akshay staff 640 Apr 23 01:51 Homebrew
drwxrwxrwx 159 akshay staff 5088 Apr 22 10:00 bin
drwxrwxrwx 11 akshay staff 352 Jan 24 21:45 etc
drwxrwxrwx 46 akshay staff 1472 Apr 23 01:52 include
drwxrwxrwx 100 akshay staff 3200 Apr 22 10:00 lib
drwxrwxrwx 42 akshay staff 1344 Apr 23 01:52 opt
drwxrwxrwx 14 akshay staff 448 Apr 23 01:52 sbin
drwxrwxrwx 17 akshay staff 544 Apr 19 02:37 share
drwxrwxrwx 10 akshay staff 320 Feb 1 18:31 var

Note — Please use your group name in place of staff . This doesn’t change the rights of brew folders anymore (like in other answers), it changes subfolders/files of brew folders. brew install should now work fine without errors.

I hope it will work. If you feel it was useful for you then please press the clap.

--

--

Akshay Kumar
Mac O’Clock
0 Followers
Writer for

I am a Postgraduate Engineer (M.Tech — Computer Science and Engineering) from NITK. I am passionate about learning new things.