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
ls -a
to see the hidden file as .[your_file].swp
, next, try to remove it. Worked!
Mar 23, 2021 at 3:35
Was happening for me because I was out of disk space, I cleared up some space, deleted the swap file and it worked.
Please try this one (run this on the current folder):
find . -name "*.swp" -delete
Keep in mind that as @pbhj commented:
[...] this will find all files below the current root, ending in .swp, and delete them. Which should work to remove temporary nano files, but might have unintended consequences.
This happened for me because of a log file that wasn't rotating, it took the entire disk space, I solved it by truncating this log file, then removing the .swp file.
For me this was because of running docker container logs.
Worked fine after deleting them.
Logs location: /var/lib/docker/containers/
rm -rf /var/lib/docker/containers/*
Note: this will delete all the log generated till today, you may choose to deleted not required and also take backup to avoid logs data loss.
nano --version
nano
- do other text editors work with this file? You may need to upgrade yournano
version to resolve depending on a the results of anano --version
.vi /etc/.profile.swp
.