Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 2 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
3  
Running cygwin as administrator allowed me to edit the file. Thanks for your help – Nope Mar 20 '11 at 18:05
1  
@Nope You should accept the newer answer posted by Philipp if you ever sign on again! – Matthew Sep 30 '14 at 21:06

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

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .