Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 182010
 

Save a file in vim without the needed permissions

Answer:

Very often, you opened a file using vim, edited it and find out that the file is opened as read only, i.e. you don't have permission to make any change(s).

What will you do? Simplest method is to save it into a temp file and rename it afterward.

However, there exist a simple method that allow you to save the file anyway.

Instead of using :wq, you enter the following.

:w !sudo tee %

That is what you need.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>