bash - 权限被拒绝在 mac 上编辑 .bash_profile rbenv init
问题描述
在 mac 上运行 rbenv init 时挂断了编辑 .bash_profile。
$ rbenv init
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
但收到消息:-bash: /Users/macbookpro/.bash_profile: Permission denied
我尝试直接编辑 .bash_profile 但收到消息:
我找到了这个命令来查看用户:
$ ls -la ~ | grep bash
表明:
-rw------- 1 macbookpro .bash_history
-rw-r--r-- 1 root .bash_profile
如果我使用命令打开文件:
$ sudo nano ~/.bash_profile
我想我需要将其添加到 .bash_profile:
$ export PATH="$HOME/.rbenv/bin:$PATH"
或者它只是这个的内在“部分”?另外,我该如何保存或者我们有更简单的解决方案(假装我的名字是 Fname-Lname)?
解决方案
您需要使用sudo
才能~/.bash_profile
在macOS
.
sudo echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
或者就像你在问题结束时所做的那样。
推荐阅读
- c++ - 用于创建线程并加入可变数量线程的循环
- android - “windowSoftInputMode=stateHidden”不适用于 Instant Run
- ios - 如何检查 Firebase 实时数据库中是否已存在 childByAutoID()?
- c++ - libclang 可以告诉我一个函数是否有弱链接吗?
- c# - C# DataGridView 行未显示 - Windows 窗体已损坏
- c++ - 从二叉搜索树中删除节点 - 错误答案
- centos7 - 如何卸载 ArangoDB
- azure - 如何控制 Azure Event Grid 触发器的并发性
- javascript - 带有 JavaScript 变量的 SVG 旋转问题
- spring - Spring Boot Admin Console 2.0.4 如何使墙板不安全?