sudo - e ~ /开放。mac bash_profile没有权限

时间:2021-08-08 02:37:42

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

我正在尝试编辑bash_profile文件,通过我的mac机器上的以下命令为我的sdk添加路径。sudo联系~ / . bash_profile;开放- e ~ / . bash_profile

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.

它在TextEdit中打开文件,但不允许我编辑它。虽然我在运行上面的命令时已经给了超级用户权限和密码。当我试图编辑它时,它会给我以下信息。

"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.

"你没有文件"bash_profile”并没有写入权限。您可以复制此文档并编辑该副本。只有副本包含您的更改。我是麦克的新手,请详细说明你的答案。

1 个解决方案

#1


9  

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:

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

sudo chown farheen ~/.bash_profile

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

作为超级用户,这将把文件的所有者返回给您。

#1


9  

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:

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

sudo chown farheen ~/.bash_profile

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

作为超级用户,这将把文件的所有者返回给您。