🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

How to stop warnings when opening a file that has a .swp file Linux?

How to stop warnings when opening a file that has a .swp file?

What is .SWP file?

When someone mentions a "swap file", the first thing that comes into your mind might be the kind of file that you would create to increase the swap space on a Unix system. Think swapfile and the swapon command. But there's another kind of swap file that comes into play, generally when you're trying to edit a file that might have encountered some difficulties during a prior edit.That type of swap file is created by your system to help ensure that you don't lose important file content when something goes wrong. And it generally sits in the same directory as the original file and has .swp as its extension.


swap-file-attension1

What is the Cause of getting this temprory .swp file generated?

  • When you start a edit session using vim editor and some problem occure and you did not saved file and quite. +If some one is editing that file remotely and you also try to open it with vim editor.

in those case we get below attension message.

E325: ATTENTION
Found a swap file by the name ".laravel.log.swp"
          owned by: root   dated: Wed Jun 10 17:03:49 2020
         file name: /opt/lampp/htdocs/mhn-admin-ms/storage/logs/laravel.log
          modified: no
         user name: root   host name: ip-172-31-20-213
        process ID: 16030 (still running)
While opening file "laravel.log"
             dated: Wed Jun 10 17:03: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 laravel.log"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".laravel.log.swp"
    to avoid this message.

Swap file ".laravel.log.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

The above attension will not occure if you started an edit session and made changes and saved the file and qite using :wq

These swap files store content for the specific file for example. when you start edit session these .swp file will be generated and will be removed once youe save and quite the session without any intruption.

In My case i was trying to open laravel.log file in side my laravel project directory and i got this attension message.

Step 1.

I got attention with below option.

Swap file ".laravel.log.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

Step 2.

Check whether the file which you want to edit exist or not usinf command 'ls -la'

Here file is already there with a temp file haveing .swp extension.

swap-file-warning2

Step 3.

If the file crashed of missed due to glitch then select (R)cover option to recover file.

Step 4.

If file already exist(In my case its already there) then just remove .swp file using below command

'rm ..swp'

swap-file-attension3

Step 5.

Then open file using vim

'vim laravel.log' and your file is ready to eding on vim editor. swap-file-warning4

swap-file-warning5


Thanks .... if you have any query ask your question in comment box


'

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.