Short Question:
Why can we manipulate a read-only file in Vim using : + w + q + ! even without being an administrator?
Long Question:
I have a text file (myFile.txt) which is read-only for everyone:
navid@navid-ThinkPad-T530:~/ubuntuTest$ ls -l myFile.txt
-r--r--r-- 1 navid navid 26 Aug 22 21:21 myFile.txt
I can open it with Vim without having admin privileges:
navid@navid-ThinkPad-T530:~/ubuntuTest$ vi myFile.txt
I modify it and press: Esc + : + w + q + Enter and I see this error message:
E45: 'readonly' option is set (add ! to override)
So far, everything makes sense. But when I press: Esc + : + w + q + ! + Enter, Vim saves the changes.
I'm using Ubuntu 16.04 and VIM 7.4.
Modifying a file and replacing a file are two different things
– Panagiotis Tabakis Aug 23 '16 at 18:02!
tries tochmod
the file to save your edits. – waltinator Aug 24 '16 at 23:04!
will not override a read-only filesystem or device. – waltinator Aug 24 '16 at 23:06