Many times, it happens while using raspberry pi that we’re not able to edit some particular files. For me it has happened with
- Motion.conf file, which is used to configure the video streaming service called motion on raspberry pi
- Rc.local, this file resides in /etc and is used for adding commands to run programs on boot
What happens sometimes, is due to wrong file closure, or opening/closing while the file is being used, the file gets locked in the memory of the operating system and we just need to remove the residual stuffs which is causing this file to remain locked.
How to identify the problem? Whenever you try to open this locked file, say for example using a text editor like nano, you’ll get below error
Now to resolve this issue, please follow below steps
Go to the exact location in your terminal, where your expected file is residing for opening, in my case, it was /etc/motion/ here I had motion.conf file which I needed editing but I was getting above nerror
Now use this command to delete the swap file that is created, as long as the swap is there, you can’t edit the original file, so the command is
sudo rm .Filename.extention.swp, please mind the initial dot (.) is compulsory, so in my case, the command was
sudo rm .motion.conf.swp and hit enter
now try opening that file using your usual editor like nano, and the file will open normally now
sudo nano motion.conf
Hello. This post was extremely interesting, especially because I was looking for thoughts on this topic
last Thursday.
Best regards,
Balle Raahauge
Thank youuuuu,
Thanks alot that what exactly happened with me , the raspberry pi was turned off suddenly and the file didn’t open i did your method and worked .
Thanks alot for sharing your experience
Am glad it helped 😊
Thank you.
sudo rm .config.txt.swp
Before that ,cannot open /boot/config.txt
after sudo rm .filename.ext.swp, can edit.