sudo open -e ~/.bash_profile 权限被拒绝 mac [英] sudo open -e ~/.bash_profile Permission denied mac

查看:30
本文介绍了sudo open -e ~/.bash_profile 权限被拒绝 mac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编辑 bash_profile 文件以在我的 mac 机器上通过以下命令添加到我的 sdk 的路径.须藤触摸 ~/.bash_profile;open -e ~/.bash_profile

I am trying to edit bash_profile file to add path to my sdk through the following command on my mac machine. sudo touch ~/.bash_profile; open -e ~/.bash_profile

它在 TextEdit 中打开文件但不允许我编辑它.尽管我在运行上述命令时已授予超级用户权限和密码.当我尝试编辑它时,它给了我以下消息.

It opens the file in TextEdit but does not allow me to edit it. Though i have given super-user permission and password while running the above command. It is giving me following message when i try to edit it.

您不拥有文件.bash_profile"并且没有写入权限.您可以复制此文档并编辑副本.只有副本会包含您的更改."我是 mac 新手.所以请详细说明你的答案.

"You don’t own the file ".bash_profile" and don’t have permission to write to it. You can duplicate this document and edit the duplicate. Only the duplicate will include your changes." I am new to mac. So please elaborate your answers.

推荐答案

问题是该文件不属于您的用户,而是属于 root.您需要将文件的所有者更改为您的用户,然后您可以在不使用 sudo 的情况下打开和编辑文件:

The problem is that the file isn't owned by your user, but by root. You need to change the owner of the file to your user, then you can open and edit the file without the use of sudo:

sudo chown farheen ~/.bash_profile

作为超级用户,这会将文件的所有者更改回您.

This will, as the super-user, change the owner of the file back to you.

这篇关于sudo open -e ~/.bash_profile 权限被拒绝 mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆