[sent privately by mistake]
On Mi, 22 mai 13, 19:48:37, Beco wrote:
> Dear users,
>
> I'm astonished by this (maybe I'm naive and I'm missing something).
>
> Yesterday as root I saved a file skel.bashrc in my /home/beco user, owned
> by root, group root.
>
> Today I edited it, logged as beco, and vi told me "warning, read only!". I
> edited anyway, just to test, and saved with :w!
>
> After that I checked the file and it has changed to owner beco, group beco.
>
> How is that possible?
Check this out:
amp@sid:~$ sudo touch tmp/testfile
amp@sid:~$ ls -l tmp/testfile
-rw-r--r-- 1 root root 0 May 23 01:58 tmp/testfile
amp@sid:~$ rm tmp/testfile
rm: remove write-protected regular empty file `tmp/testfile'? y
amp@sid:~$ ls -l tmp/testfile
ls: cannot access tmp/testfile: No such file or directory
amp@sid:~$
AFAIR it has to do with the fact that you own the directory and rm just
deletes the directory entry for that file.
With vi(m) (and I assume most other editors) this works because when you
edit a file you don't work on the actual file, but on a copy of it. When
you save it vi(m) replaces the original file with the changed copy
(effectively rm/rename), because in case of a crash/power failure/etc.
you still have the original and hopefully even most of the changed file
(depending on autosave settings).
Hope this explains,
Andrei
--
If you can't explain it simply, you don't understand it well enough.
(Albert Einstein)