use*_*691 5 environment-variables vi 16.04
我之前已经更改过环境变量。当我尝试使用以下命令时:
sudo vi /etc/environment
Run Code Online (Sandbox Code Playgroud)
我收到以下警告/错误,并且对下一步该做什么感到困惑。
E325: ATTENTION
Found a swap file by the name "/etc/.environment.swp"
owned by: root dated: Wed Apr 18 15:03:44 2018
file name: /etc/environment
modified: no
user name: root host name: my-desktop
process ID: 6410
[not usable on this computer]
While opening file "/etc/environment"
dated: Wed Apr 18 14:49:02 2018
(1) Another program may be editing the same file. If this is the
case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/environment"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/.environment.swp"
to avoid this message.
"/etc/environment" 6 lines, 389 characters
Press ENTER or type command to continue
Run Code Online (Sandbox Code Playgroud)
那么有人可以向我解释一下下一步该做什么以及这条消息的真正含义吗?
更新:我尝试按照建议进行操作。我按了e它,它打开了环境文件,然后我按了i编辑它并更改了我的nodejs版本(最初是9.x,我将其改为8.x),然后我按了Esc然后然后shift+;然后wq|x之后我终于按下了它Enter,它关闭了 vi 编辑器,之后我再次运行了相同的命令,但它给了我相同的错误,但进一步更新说明NEWER than swap file!
完整讯息如下:
E325: ATTENTION
Found a swap file by the name "/etc/.environment.swp"
owned by: root dated: Wed Apr 18 15:03:44 2018
file name: /etc/environment
modified: no
user name: root host name: my-desktop
process ID: 6410
[not usable on this computer]
While opening file "/etc/environment"
dated: Mon May 14 16:53:13 2018
NEWER than swap file!
(1) Another program may be editing the same file. If this is the
case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/environment"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/.environment.swp"
to avoid this message.
"/etc/environment" 7 lines, 390 characters
Press ENTER or type command to continue
Run Code Online (Sandbox Code Playgroud)
所以不知道怎么解决!
这意味着您或其他用户已经开始编辑该文件,并且有未保存的更改。您可能打开该文件,开始编辑它,然后退出 Vi 而不进行写入。
说明会告诉您该怎么做。
您可以按r恢复文件,您将看到包含未保存更改的版本。进行编辑。
如果您不想恢复未保存的更改,请按q退出并删除消息中提到的文件
sudo rm /etc/.environment.swp
Run Code Online (Sandbox Code Playgroud)
然后你可以再次打开它并找到上次保存的版本。
当您想要保存更改并退出时,请按esc并键入:wq。
但是,您确定需要编辑/etc/environment吗?考虑是否最好使用每用户配置文件,例如~/.profile。
| 归档时间: |
|
| 查看次数: |
86571 次 |
| 最近记录: |