I have a file named
file.txt with some contents located in
/home/myuser directory and I change the permissions of that file to
-rw-r--r-- 1 root root 1.4K Jan 15 07:09 file.txt
Then I switched to
myuser and opened it with
vim(without sudo) and tried to edit and save it
:wq! and I got output like:
"file.txt" E949: File changed while writing
Press ENTER or type command to continue
Then I hit enter and then again
:wq! and the output was :
WARNING: The file has been changed since reading it!!!
Do you really want to write to it (y/n)?
y, the file got saved and exit from
The question is why a file with
ROOT privileges and
read-only access for a user changed by the way?
myuser is a sudo user.
The user permissions after saving the file changed to
-rw-r--r-- 1 myuser myuser 1.4K Jun 27 18:57 file.txt