Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to edit /etc/hosts using Vi in Cygwin but it's read only. Is there a command similar to sudo? How do I edit a read-only file?

Thanks

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Try doing a forced overwrite. Instead of :wq to write and quit, try: :wq! to force write and quit.

share|improve this answer
    
Didn't work.... –  Nope Mar 20 '11 at 17:57
3  
Try using the Windows runas command then? runas /user:Administrator vi /etc/hosts –  Majenko Mar 20 '11 at 17:59
2  
Running cygwin as administrator allowed me to edit the file. Thanks for your help –  Nope Mar 20 '11 at 18:05

Opening your cygwin shell as Administrator will grant your user root access. Then the files will no longer be readonly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.