For example, root touch a new file under a common user's(name it bob) home directory:
/home/bob $ ls -alh a.txt
-rw-r--r-- 1 root root 0 Jul 16 17:45 a.txt
Now user bob open it with vim, and it should be readonly.
I tried to force overwrite it with :w!
, and it was saved and the owner:group
changed to bob:
/home/bob $ ls -alh a.txt
-rw-r--r-- 1 bob bob 4 Jul 16 17:47 a.txt
IMO, I think it can't be saved with permission denied, but it could, and the owner:group also changed.
And this can only under bob's home directory, if under outer directory, such as /tmp or others, it can't be written as I thought.
Can anyone explain this? what processes does :w!
actual do? thx.