情景再现 我在一次使用vim编辑文件的时候,习惯性的按了ctrl+s想保存,然后屏幕就卡住了,最后我使直接暴力推出了终端,再次编辑想保存的时候就出了下面的警告提示: E325: ATTENTioNFound a swap file by t
我在一次使用vim编辑文件的时候,习惯性的按了ctrl+s
想保存,然后屏幕就卡住了,最后我使直接暴力推出了终端,再次编辑想保存的时候就出了下面的警告提示:
E325: ATTENTioNFound a swap file by the name "/etc/.profile.swp" owned by: root dated: Sat Feb 4 10:57:53 2023 file name: /etc/profile modified: YES user name: root host name: TTK-ALI-ESC-1 process ID: 26006While opening file "/etc/profile" dated: Sat Feb 4 10:59:20 2023 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/profile" to recover the changes (see ":help recovery"). If you did this already, delete the swap file "/etc/.profile.swp" to avoid this message.Swap file "/etc/.profile.swp" already exists![O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
enter
可以进入编辑,编辑完wq
保存的时候提示E45: 'readonly' option is set (add ! to override)
,加上!确实可以强制保存,但是这个问题会一直存在xxx.swp
文件,拥有者是root
,时间是Sat Feb 4 10:57:53 2023
,当你想要编辑这个文件的时候,时间比这个swp文件新,大概有点感觉了,像是个版本控制的东西,冲突了。再翻译一下下面大段的(1)(2)# 翻译(1)另一个程序可能正在编辑同一个文件。 如果是这种情况,注意不要以相同的两个不同实例结束进行更改时的文件。 退出,或谨慎继续。(2)此文件的编辑会话崩溃。 如果是这种情况,请使用 ":recover" 或 "vim -r /etc/profile" 恢复更改(参见“:help recovery”)。 如果您已经这样做了,请删除交换文件“/etc/.profile.swp” 以避免此消息。
xxx.swp
中保存了上次编辑的内容,然后你再次编辑文件会和上次的编辑产生冲突解决办法在报错信息(2)中已经说的很清楚了使用vim -r /etc/profile
打开并编辑,我尝试后发现其实是根据xxx.swp
文件来继续完成上次异常退出时的编辑内容。如果你已经这样做了,或者不在乎上次编辑的内容,可以直接删掉xxx.swp
文件。
注意
# 先到对应目录下看看是否真的有这个东西,注意这是个隐藏文件,需要加参数-als -a# 直接删除即可,后面是你自己的那个.xxx.swp文件rm -rf .profile.swp
再次尝试编辑,问题解决
补充:
ctrl+s
在linux里是暂停的意思,因此让我产生了一种卡死的错觉,可以用ctrl+q
退出这种状态
来源地址:https://blog.csdn.net/T1401026064/article/details/128882296
--结束END--
本文标题: Linux系统下Found a swap file by the name “xxx.swp“问题出现的原因及解决方法
本文链接: https://www.lsjlt.com/news/379994.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0