問題
# brew install tree Updating Homebrew... Error: The following directories are not writable by your user: /usr/local/share/man/man8 You should change the ownership of these directories to your user. sudo chown -R $(whoami) /usr/local/share/man/man8 And make sure that your user has write permission. chmod u+w /usr/local/share/man/man8
於是
sudo chown -R $(whoami) /usr/local/*
但是
╰─$ sudo chown -R $(whoami) /usr/local/* sudo: /etc/sudoers is owned by uid 501, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin
501 是我當前登錄的用戶 nahongze ,而 0 應該是 root 用戶。
解決
系統偏好設置 -> 用戶與群組 -> 登錄選項 -> 網絡賬戶服務器 -> 加入 -> 打開目錄實用工具 -> 解鎖 -> 頂部菜單欄 -> 目錄編輯器 -> 搜root 啟用 Root 用戶
打開終端切換到root
chown root:admin /etc/sudoers