Homebrew Multi User Setup

leif hanack
2 min readOct 4, 2017

--

Homebrew is still one of my first installations on a new Mac and a must have IMO. If you use an admin user and an standard user on your Mac, here is the setup.

Allen the admin and Stan the standard user. Stan is a developer who works most of his time inside our company network. Allen is responsible for installing apps and so on. For security reasons Stan don’t want to be admin. Nevertheless Stan wants to use homebrew, he loves it too. Allen don’t want to have two homebrew installations so that he allows Stan to use his homebrew.

Setup

  1. Create a group brew and add Stan
  2. brew doctor (Allen checks if he installed brew correctly)
  3. sudo chgrp -R brew $(brew --prefix)/* (Change the group of homebrew installation directory)
  4. sudo chmod -R g+w $(brew --prefix)/*(Allow group members to write inside this directory)
  5. brew doctor (Stan checks if he can use homebrew)
  6. We are done!

Detailed Setup

Create a group brew and add Stan
One way to create a group brew is to open the System Preferences and select Users & Groups. Unlock this screen and press the lower left +. Select the account type Group and name it brew. After creating this group add Allen and Stan.

Allen checks if he installed brew correctly

allen$ brew doctor
Your system is raring to brew.

Change the group of homebrew installation directory

allen$ sudo chgrp -R brew $(brew --prefix)/*
Password:
allen$ ls -la $(brew --prefix)
total 16
drwxrwxr-x 8 root brew 272 Jun 12 22:31 .
drwxr-xr-x@ 13 root wheel 442 Jun 12 22:36 ..
-rw-r--r-- 1 admin brew 159 Jun 12 22:28 .gitignore
drwxr-xr-x 2 admin brew 68 Jun 12 22:33 Cellar
drwxr-xr-x 6 admin brew 204 Jun 12 22:28 Library
-rw-r--r-- 1 admin brew 789 Jun 12 22:28 README.md
drwxr-xr-x 3 admin brew 102 Jun 12 22:28 bin
drwxr-xr-x 3 admin brew 102 Jun 12 22:28 share

Allow group members to write inside this directory

allen$ sudo chmod -R g+w $(brew --prefix)/*allen$ ls -la $(brew --prefix)
total 16
drwxrwxr-x 8 root brew 272 Jun 12 22:31 .
drwxr-xr-x@ 13 root wheel 442 Jun 12 22:36 ..
-rw-rw-r-- 1 admin brew 159 Jun 12 22:28 .gitignore
drwxrwxr-x 2 admin brew 68 Jun 12 22:33 Cellar
drwxrwxr-x 6 admin brew 204 Jun 12 22:28 Library
-rw-rw-r-- 1 admin brew 789 Jun 12 22:28 README.md
drwxrwxr-x 3 admin brew 102 Jun 12 22:28 bin
drwxrwxr-x 3 admin brew 102 Jun 12 22:28 share

Stan checks if he can use homebrew
In my case Allen and Stan is one person, so that a simple login do the trick.

allen$ login stan
Password:
stan$ brew doctor
Your system is raring to brew.

--

--