Recusively change the owner of files (chown) on Mac OS X

I've just changed my OS X / Mac main user - I've created a new 'coder' user account that I want to use for development instead of my old 'lombard' account. I realized that a lot of my applications I've previously installed via Homebrew now had to be changed to be owned by the new coder user. First I ran 'brew doctor' find see what obvious issues I have:

Gerts-Mac-mini:src coder$ brew doctor
Warning: /usr/local/etc isn't writable.
This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a brew tries to write a file to this directory, the
install will fail during the link step.

You should probably `chown` /usr/local/etc
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

Warning: You have an outdated version of /usr/bin/install_name_tool installed.
This will cause binary package installations to fail.
This can happen if you install osx-gcc-installer or RailsInstaller.
To restore it, you must reinstall OS X or restore the binary from
the OS packages.

Warning: Git could not be found in your PATH.
Homebrew uses Git for several internal functions, and some formulae use Git
checkouts instead of stable tarballs. You may want to install Git:
  brew install git

Warning: No developer tools installed.
Install the Command Line Tools:
  xcode-select --install
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

Indeed, several files/directories below '/usr/local' were created by Homebrew as user 'lombard':

Gerts-Mac-mini:src coder$ ls -l /usr/local
total 80
-rw-r--r--   1 lombard  admin   3158  5 Jun 09:16 CODEOFCONDUCT.md
-rw-r--r--   1 lombard  admin    687  5 Jun 09:16 CONTRIBUTING.md
drwxr-xr-x   4 lombard  admin    136 17 Jun 17:11 Cellar
-rw-r--r--   1 lombard  admin   1253  5 Jun 09:16 LICENSE.txt
drwxr-xr-x   9 lombard  admin    306 17 Jun 17:11 Library
-rw-r--r--   1 lombard  admin   1858  5 Jun 09:16 README.md
-rw-r--r--   1 lombard  admin  23719  5 Jun 09:16 SUPPORTERS.md
drwxrwxr-x  12 root     admin    408 17 Jun 17:11 bin
drwxr-xr-x   3 lombard  admin    102 17 Jun 17:11 etc
drwxrwxr-x   5 root     admin    170 17 Jun 17:11 lib
drwxr-xr-x   3 root     wheel    102 17 Jun 17:11 libexec
drwxrwxr-x   4 root     admin    136 17 Jun 17:11 share

I can't just use 'chown -R' because I only want to change the owner of some specific files. To recursively fix/change the owner only of files specifically owned by another user, use the versatile 'find' command:

$ find . -user lombard -exec sudo ch
own coder {} \;

Now I just took care of the other things that brew doctor complained about:

$ xcode-select --install
$ brew update

That's it! Now I'm ready to install more tools using Homebrew using the new user account.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值