Getting error while opening /etc/profile: Error reading lock file /etc/.profile.swp: Not enough data read

I am getting this error while opening /etc/profile file using nano.

Error reading lock file /etc/.profile.swp: Not enough data read

How can I fix this?


Try to remove the hidden file .[yourfilename].swp, which is stored in the same folder as the file that you are trying to open.
In your case try the shell command rm /etc/.profile.swp.

This issue also occurs with nano 2.7.4, and must be something to do with how nano handles a corrupted swapfile.

Hope this helped


The problem is linked to a bug in an older version of nano as seen here.

As per the report, the affected version was nano-2.4.2. You should run nano --version to ascertain your current version and update accordingly.

A more detailed report of the actual issue can be found here.


Was happening for me because I was out of disk space, I cleared up some space, deleted the swap file and it worked.