Linux系统下Found a swap file by the name “xxx.swp“问题出现的原因及解决方法

这篇具有很好参考价值的文章主要介绍了Linux系统下Found a swap file by the name “xxx.swp“问题出现的原因及解决方法。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

情景再现

我在一次使用vim编辑文件的时候,习惯性的按了ctrl+s想保存,然后屏幕就卡住了,最后我使直接暴力推出了终端,再次编辑想保存的时候就出了下面的警告提示:

E325: ATTENTION
Found 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: 26006
While 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:
问题分析
  1. enter可以进入编辑,编辑完wq保存的时候提示E45: 'readonly' option is set (add ! to override),加上!确实可以强制保存,但是这个问题会一直存在
  2. 然后如果我们认真的看了情景再现中的报错信息,那么会发现给你说的已经清清爽爽了,首先大概的意思是发现了一个和你想要编辑的文件同名的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”
     以避免此消息。
  1. 很明显是因为你的编辑会话崩溃了(异常关闭),vim给你在临时文件xxx.swp中保存了上次编辑的内容,然后你再次编辑文件会和上次的编辑产生冲突
解决方法

解决办法在报错信息(2)中已经说的很清楚了使用vim -r /etc/profile打开并编辑,我尝试后发现其实是根据xxx.swp文件来继续完成上次异常退出时的编辑内容。如果你已经这样做了,或者不在乎上次编辑的内容,可以直接删掉xxx.swp文件。
注意

# 先到对应目录下看看是否真的有这个东西,注意这是个隐藏文件,需要加参数-a
ls -a
# 直接删除即可,后面是你自己的那个.xxx.swp文件
rm -rf .profile.swp

再次尝试编辑,问题解决

补充: ctrl+s在linux里是暂停的意思,因此让我产生了一种卡死的错觉,可以用ctrl+q退出这种状态文章来源地址https://www.toymoban.com/news/detail-427321.html

到了这里,关于Linux系统下Found a swap file by the name “xxx.swp“问题出现的原因及解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Component is not found in path “components/xxx/xxx“ (using by “pages/xxx/xxx“) 问题记录

    相信做过小程序的都遇到过Component is not found in path “components/xxx/xxx“ (using by “pages/xxx/xxx“) 这个问题,一般情况的是引用路径有问题,检查代码路径改对就好了,又或者是 分包 影响的 先说一下我得使用场景,不一定适用于所有人,只是记录一下我遇到的 1.小程序是分包的

    2024年02月02日
    浏览(37)
  • unity error CS0246: The type or namespace name ‘xxx‘ could not be found (are you missing a using

    unity 导入了Bitmap使用后报错: error CS0246: The type or namespace name ‘XXX’ could not be found (are you missing a using directive or an assembly reference?) 解决方案如下: .NET Standard 2.1与 .NET Foundation 发布的 .NET Standard 2.1 配置文件匹配。 Unity 建议新项目使用 .NET Standard 2.1。 它比 .NET 4.x 小,有利于尺

    2024年04月26日
    浏览(29)
  • 记一次git pull报错问题 is owned by: ‘xxx‘ but the current user is ‘xxx‘

    使用git pull命令报错 fatal: detected dubious ownership in repository at \\\'D:/xxx/myapp\\\' \\\'D:/xxx/小程序后台/myapp\\\' is owned by:         \\\'S-1-5-21-1208550113-1887591142-738254596-1000\\\' but the current user is:         \\\'S-1-5-21-322366719-3789332941-2827711459-500\\\' To add an exception for this directory, call:         git config --global -

    2024年02月11日
    浏览(38)
  • 2 files found with path ‘lib/arm64-v8a/xxx.so‘ 问题解决

    目录 2 files found with path ‘lib/arm64-v8a/xxx.so‘ 问题 2 files found with path \\\'META-INF/DEPENDENCIES\\\' from inputs:报错 解决方法: 在报该编译错误的module的build.gradle中加入如下配置项,排除掉中间生成的lib/arm64-v8a/xxx.so 解决办法 在报该编译错误的module的build.gradle中加入如下配置项,排除掉中

    2024年02月11日
    浏览(40)
  • [vue3打包时出现的问题]File ‘xxx‘ is a JavaScript file. Did you mean to enable the ‘allowJs‘ option?

     今天在打包vue3+ts的项目是遇到了一个错误信息:is a JavaScript file. Did you mean to enable the \\\'allowJs\\\' option? (是一个javaScript文件。你是否要启用‘allowJs选项?’)错误信息如下: 查了一下说是由于我们的项目配置中缺少了‘allowJs’选项导致的。当我们在使用TypeScript编辑器编译项

    2024年03月23日
    浏览(31)
  • Unity3d2021版本 使用DOTween插件报错The type name ‘Rigidbody2D‘ could not be found in the namespace ‘****‘问题

    最近在升级项目至2021版本的过程中发现了诸多这种问题,今天就遇到这样的报错: AssetsPluginsDemigiantDOTweenModulesDOTweenModulePhysics2D.cs(143,18): error CS1069: The type name ‘Rigidbody2D’ could not be found in the namespace ‘UnityEngine’. This type has been forwarded to assembly ‘UnityEngine.Physics2DModule,

    2024年02月11日
    浏览(43)
  • 【问题解决】 Could not find a package configuration file provided by “OpenCV“ with any of the following n

    编译依赖于opencv的包时报错 Could not find a package configuration file provided by “OpenCV” with any of the following names: OpenCVConfig.cmake opencv-config.cmake 这个问题是找不到 “OpenCVConfig.cmake” 或 “opencv-config.cmake” 文件,主要是找不到 OpenCV 路径而导致的。 造成这个问题的主要原因就是没有安

    2024年03月18日
    浏览(43)
  • Xcode报fatal error: ‘XXX.h‘ file not found

    在Xcode中遇到 \\\"fatal error: \\\'XXX.h\\\' file not found\\\" 的错误通常是由于缺少头文件或头文件路径配置不正确导致的。 以下仅为我的解决方案: 如果有多层文件夹则需要以 / 间隔如下 XXX为文件夹名 $(PROJECT_DIR)/XXX/XXX/XXX

    2024年02月22日
    浏览(36)
  • Unity解决动画不可用:The AnimationClip ‘XXX‘ used by the Animation component ‘XXX‘ must be marked as Legacy.

    在Unity 2019.4.38.f1c1以上的版本,创建的创建Animation Clip无法使用,作为组件的默认Clip的话,那么游戏运行的时候这个Clip其实是播不出来的,而且Console会报一条 “The AnimationClip ‘XXX’ used by the Animation component ‘XXX’ must be marked as Legacy.” 的警告信息,以及一条 “Default clip co

    2023年04月08日
    浏览(38)
  • OC和Swift混编,导入头文件‘xxx-Swift.h‘ file not found

    在OC的项目里加入Swift代码,创建完桥接文件后,需要倒入Swift头文件,头文件的格式为“项目名-Swift.h”。 如下图,我在Xcode上看到我的项目名为YichangPark,导入 #import \\\"YiChangPark-Swift.h\\\" 之后提示 “YiChangPark-Swift.h”file not found. 言外之意,就是没有找到头文件! 解决办法: 1

    2024年02月10日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包