mac root用戶失去權利 【/etc/sudoers is owned by uid 501, should be 0】


問題

# 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

參考 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM