重庆思庄Oracle、Redhat认证学习论坛

标题: Swap file "/etc/.hosts.swp" already exists! 解决办法 [打印本页]

作者: jiawang    时间: 2020-11-25 13:16
标题: Swap file "/etc/.hosts.swp" already exists! 解决办法
故障:在使用vim编辑nginx的配置文件的时候,一直出现swp文件已存在的现象:
    在使用vim编辑某文件的时候,会产生一个swp文件
              .FILENAME.swp
  在正常编辑结束退出的时候,该文件会被自动删除


E325: ATTENTION
Found a swap file by the name "/etc/.hosts.swp"
          owned by: root   dated: Wed Nov 25 13:01:02 2020
         file name: /etc/hosts
          modified: YES
         user name: root   host name: strong
        process ID: 70264
While opening file "/etc/hosts"
             dated: Fri Jul 31 14:39:45 2020

(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/hosts"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/etc/.hosts.swp"
    to avoid this message.

Swap file "/etc/.hosts.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:


解决办法:
[root@strong etc]# ll -a .hosts.swp
-rw-r--r--. 1 root root 12288 Nov 25 13:01 .hosts.swp
[root@strong etc]# rm .hosts.swp
rm: remove regular file ‘.hosts.swp’? yes
[root@strong etc]#

[root@strong etc]# vim hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


192.168.0.145 strong
192.168.0.156 sztech
~
~
~
[root@strong etc]# cat hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6


192.168.0.145 strong
192.168.0.156 sztech







欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/) Powered by Discuz! X3.2