无法在我的Mac上编辑/ etc / profile


1

上一个问题的答案无济于事- 无法在我的Mac上编辑/ etc / profile

我想编辑/ etc / profile,但即使使用sudo打开它也无法编辑。我手动更改了文件的权限

sudo chmod u+w /etc/profile

现在,当我尝试保存文件时出现另一个错误。对话框没有显示告诉我我没有权限,而是显示“无法保存文档'配置文件'”。如何更改文件?


您正在使用什么程序通过sudo编辑文件?
肯特郡

我正在使用TextEdit
Eric Baldwin

您应该在终端机内部使用编辑器,例如emacs,vi或pico。以sudo方式运行诸如TextEdit之类的窗口应用程序不起作用。(具体来说,您应该运行“ sudo emacs / etc / profile”或“ sudo vi / etc / profile”)
肯特(Kent

u+w不是您想要的...您不是用户...如果要走那条路线,您想给小组/其他写东西。sudo chmod go+w /etc/profile
2013年

Answers:


2

如果您以root身份运行可执行文件,它应该可以工作:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit

如果您使用TextEdit 运行sudo chmod u+w /etc/profile/etc/profile正常打开,则TextEdit会显示错误,因为它没有对的写入权限/private/etc/。从10.7开始,TextEdit还需要对包含目录的写许可权,这可能与自动保存或沙箱有关。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.