26

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?

  • 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. – Pooping Feb 5 '16 at 23:06
33

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
  • 10
    Also faster hitting Y and CTRL+X; the lock is replaced by the new instance and removed upon CTRL+X. – kos Feb 5 '16 at 20:50
  • Fantastic! This worked perfectly. Thanks, Florian Diesch! – munr0 Feb 5 '16 at 21:03
  • 1
    Can't find that .syslog.swp file as of Ubuntu 16.04.1 LTS. – Frank Nocke Sep 26 '16 at 7:21
  • 9
    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 – user2972154 Oct 29 '16 at 18:20
  • one method to delete the .swp file is to use 'sudo find /path/to/.filename.swp -type f -delete' – Patrick Oct 18 '17 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.