Thursday, October 28, 2010

Forgot to use sudo?

Has it happened to you before that - you run a command and forgot to 'sudo' - and hence the commnd fails and now you need to re-run the command all over again? Well in that case this is how you can save some time.

[debu@DebaTestBox ~]$ sudo !!

Forgot 'sudo' before editing a file:

Believe me this is the most frustrating one, and it happens to me a lot to me. You edited quite a few in the file and when try to save&xit( :wq!) you see an error as below

E212: Can't open file for writing
Press ENTER or type command to continue

Well, the below is a savior un this kind of scenario

:w !sudo tee %

this will ask your password the there in, and you are done. All your edits are now recorded by Vim editor.

Cheers!!!

Hope it helps!

DK




1 comment:

  1. Great many thanks! Your post contains information that brings me a step closer to getting the bigger picture. Cheers!

    Handheld metal detector manufacturers in Chandigarh

    ReplyDelete

AWS re:Invent summary 2017

As you might know, this year’s AWS re:Invent was held @ Las Vegas 11/27 – 12/1.   Below links could be a good start to explore all ...