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


9

在终端中,我这样做:

sudo vi /etc/profile

但是我得到一个只读版本。我从来没有以超级用户身份进行过任何编辑,这是怎么回事?


什么ls -l /etc/profile发言权? -r--r--r--
Mikel

Answers:


7

/etc/profile 是只读的。

您可以使它可写

$ sudo chmod +w /etc/profile

或更好的是vi,使用覆盖一个只读文件Esc-wq!


Esc-wq!是一个很好的提示。谢谢!
sheeldotme

4

也许这不是您要执行的操作,但是如果您可以.profile在主目录中创建一个文件并在其中放置用户特定的配置更改,则不必担心/ etc / profile中的更改。但是,也许您希望更改所有用户的配置,而不仅仅是一个用户。如果是这样,那么以上两个答案就可以了。


1

运行ls -l继续/etc/profile显示,甚至所有者也不具有写权限:

$ ls -la /etc/profile 
-r--r--r--  1 root  wheel  189 May  4  2009 /etc/profile

您可以让所有者像这样编辑它:

sudo chmod u+w /etc/profile

然后,您应该可以将其编辑为root

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.