E325: ATTENTION swap file already present error in Vi
I have changed my environment variables before now. When I am trying to use the following command:
sudo vi /etc/environmentI am getting following warning/error and I am confused about what to do next.
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 continueSo can someone please explain to me what to do next and what this message really means?
UPDATE: I tried to do as suggested .I pressed e and it opened the environment file then I pressed i to edit it and changed my nodejs version (initially it was 9.x and I made it 8.x) then I pressed Esc and then shift+; and then wq|x after that I finally pressed Enter and it closes the vi editor after that again I ran the same command but it gave me same error but with further update stating NEWER than swap file!
Full message as follows:
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 continueSo don't know how to resolve it!
11 Answer
It means you or another user has already started editing the file and there are unsaved changes to it. You probably opened the file, began editing it, and then exited Vi without writing.
The instructions tell you what to do.
You can either press r to recover the file and you will see the version with the unsaved changes. Make your edits.
If you don't want to recover the unsaved changes, press q to quit and delete the file mentioned in the message
sudo rm /etc/.environment.swpThen you can open it again and find the last saved version.
When you want to save your changes and exit press esc and type :wq.
But, are you sure you need to edit /etc/environment? Consider whether you had better use a per-user config file such as ~/.profile instead.