[Novalug] Changing a readonly file to a read-write file
novalugml at jgcomp.com
Sat Oct 31 16:12:28 EDT 2009
On Sat, Oct 31, 2009 at 01:07:54PM -0400, Charles M Howe wrote:
> This is an elementary question. I have a file that is read only at the
> user level and I want to change it so that I can edit it as a user. I
> had hoped that I could use vi as root but no dice. Then I thought I
> could use chattr as root, but I read the command summary in "Linux in a
> Nutshell" and still don't see how to do it. Advice please.
as the user (or root) try 'chmod u+w file' or 'chmod ug+w file' or
'chmod a+w file' depending on whether if you want just the user (owner),
the owner and the group, or everyone to be able to write.
When in vim, you typically can overwrite a readonly file with an emphatic
write, ":w!". Vim will do the chmod command for you (if you are allowed
to do so) and reset it after writing. This would be true for the owner
of the file or for root.
The reason you "can't" do it as root is because vim is enforcing the permissions,
not the OS. The emphatic form overrides vim's protections.
Jon H. LaBadie jon at jgcomp.com
12027 Creekbend Drive (703) 787-0884
Reston, VA 20194 (703) 787-0922 (fax)
More information about the Novalug