[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gain owner of a file using vim :w!



On Wed, May 22, 2013 at 07:48:37PM -0300, 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?
> 
> Thanks,
> Beco
> 
> 
> 
> 
> -- 
> Dr Beco
> A.I. researcher
> 
> "Sometimes the heart sees what is invisible to the eye." (H. Jackson Brown
> Jr.)

According to the vim docs [0]:

:w[rite]! [++opt]   Like ":write", but forcefully write when 'readonly' is
            set or there is another reason why writing was
            refused.
            Note: This may change the permission and ownership of
            the file and break (symbolic) links.  Add the 'W' flag
            to 'cpoptions' to avoid this.

I'm not sure how this works. What were the permissions on the file before you edited it?

[0] - http://vimdoc.sourceforge.net/htmldoc/editing.html#writing
-- 
staticsafe
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
Please don't top post - http://goo.gl/YrmAb
Don't CC me! I'm subscribed to whatever list I just posted on.


Reply to: