"file /var/log/syslog is being edited" message in nano

27,289

If the option "vim-style lock-files" is enables (set locking in nanorc), which is the case by default, nano creates a special so called "lock file" while you edit a file to indicate that the file is currently edited.

Normally this file is removed when nano is closed, but that doesn't happen if you kill it by closing the terminal.

Just remove the file

/var/log/.syslog.swp
Share:
27,289

Related videos on Youtube

munr0
Author by

munr0

Updated on September 18, 2022

Comments

  • munr0
    munr0 over 1 year

    To the best of my knowledge, I can view /var/log/syslog with the command

    sudo nano /var/log/syslog
    

    and successfully did so several times during a session; however, I was trying to search the log for keywords and apparently entered some 'unknown commands' by mistake. The terminal froze, so I killed it to try starting over.

    Now, when I issue the command above, I get what appears to be a blank file with the prompt at the bottom of the terminal window:

    File /var/log/syslog is being edited (by root using Nano 2.4.2) CONT

    with options, Yes, No and Cancel.

    Why is this happening? Have I screwed up my syslog file? If so, how dire is that?

    • Pooping
      Pooping over 8 years
      When the terminal appears frozen, sometimes this happens because ctrl-s was pressed which causes the display to stop updating. To recover from that, press ctrl-q. Also, if you don't intend on editing a file, consider using something like less instead of an editor so you don't inadvertently make changes.
  • kos
    kos over 8 years
    Also faster hitting Y and CTRL+X; the lock is replaced by the new instance and removed upon CTRL+X.
  • munr0
    munr0 over 8 years
    Fantastic! This worked perfectly. Thanks, Florian Diesch!
  • Frank Nocke
    Frank Nocke over 7 years
    Can't find that .syslog.swp file as of Ubuntu 16.04.1 LTS.
  • user2972154
    user2972154 over 7 years
    For Ubuntu 16.04 LTS the nano lock file, as explained by Florian Diesch, is located in the path of the file being edited and takes the hidden name of the file with the suffix .swp. > Thus if editing /path/to/file, the corresponding lock file is /path/to/.file.swp. Delete the .file.swp to release the lock
  • Patrick
    Patrick over 6 years
    one method to delete the .swp file is to use 'sudo find /path/to/.filename.swp -type f -delete'
  • user25
    user25 about 6 years
    linux sucks, why such problems? I closed all terminal windows, where is it still used?
  • user25
    user25 about 6 years
    no such file: sudo rm $HOME/.bashrc.swp, and can't still access nano $HOME/.bashrc File .../.bashrc is being edited (by root with nano 2.5.3, PID 24112); continue
  • Pablo Bianchi
    Pablo Bianchi over 5 years
    Also say "...with nano 2.5.3, PID 18017". Where did it get that PID? Is not on hidden swp file. Sometimes it doesn't exist.
  • Bobort
    Bobort about 4 years
    @kos, you should really make your comment an answer! It's the only reasonable thing to do!
  • steveb
    steveb over 3 years
    @kos I am late to this question but, your comment solved my problem. The file this answer refers to, didn't exist for me.