【问题标题】:you dont own the file shells popup when editing shells file您不拥有文件 shell 编辑 shell 文件时弹出
【发布时间】:2021-09-25 07:50:44
【问题描述】:

我正在学习本教程:

https://betterprogramming.pub/setting-up-your-mac-for-web-development-in-2020-659f5588b883

我被困在这部分:

To update our default shell to be Homebrew’s Zsh, we need to edit the shell’s whitelist: sudo vim /etc/shells. (If you’re not comfortable with Vim, you can use TextEdit instead by running sudo open /etc/shells.)
Add a new line with /usr/local/bin/zsh, save, and close.
To change the default shell, run: chsh -s /usr/local/bin/zsh.

当我运行 sudo open /etc/shells 并尝试编辑时,它说我不拥有文件外壳并且我无法编辑文件。我是 MacOS 的新手,所以不确定我做错了什么......

【问题讨论】:

    标签: bash macos zsh


    【解决方案1】:

    sudo open ... 以 root 身份运行 open,但 open 本身实际上并没有打开文件:它只是向 TextEdit 发送请求以打开文件,然后以普通用户身份运行。

    但是,您不需要编辑器来进行此更改。只需使用 tee 将新行附加到文件中即可:

    echo "/usr/local/bin/zsh" | sudo tee -a /etc/shells
    

    tee 将以 root 身份运行; -a 选项告诉tee 将其输入追加/etc/shells,而不是覆盖现有内容。

    【讨论】:

      猜你喜欢
      • 2016-08-10
      • 1970-01-01
      • 1970-01-01
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-16
      • 2015-08-31
      相关资源
      最近更新 更多