Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > modify & save hosts file

modify & save hosts file
Thread Tools
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Dec 12, 2005, 10:25 AM
 
i have searched and found some items similar, but nothing had the answer i am looking for: how do i save my edited hosts file? i'm running 10.4.3.

when i open /etc/hosts, with textedit or vi, it is opened as read-only and will not let me save it. i have set my permissions to 766 and 777, to make sure it is editable, but then i still cannot save my changes. in textedit when i save changes, i am told i can't save due to overwrite protection (i think that was the message) and when i choose to overwrite, it does not allow me to save. through vi, i get a message related to /private/etc/hosts.

do i need to change the permissions on /private/etc/hosts as well? or am i missing something very simple to let me save changes to /etc/hosts? i also tried to make the modification using NetInfo, and it does not save the change either.

thanks!
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status: Offline
Reply With Quote
Dec 12, 2005, 10:45 AM
 
Are you editing as root? (sudo vi /etc/hosts)

pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
     
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Dec 12, 2005, 10:50 AM
 
Originally Posted by Tesseract
Are you editing as root? (sudo vi /etc/hosts)
i am. going in as root should protect from the overwrite protection, right?
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
Mac Elite
Join Date: Sep 2005
Location: Vancouver, BC
Status: Offline
Reply With Quote
Dec 12, 2005, 11:03 AM
 
If a file is r-xr--r-- root/root, and you are su'ed as root, then you can still write to it simply because you are *root*, even though you don't have the "official" write flag. In vi/vim, rather than doing :w to write the file out, do :w! and it will force an overwrite.
     
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Dec 12, 2005, 11:16 AM
 
Originally Posted by Tomchu
If a file is r-xr--r-- root/root, and you are su'ed as root, then you can still write to it simply because you are *root*, even though you don't have the "official" write flag. In vi/vim, rather than doing :w to write the file out, do :w! and it will force an overwrite.
thx; i will give that a shot (using :w!). if i were to use 'wq!' it will not have the same effect as 'w!' right?

su and sudo will give me the same rights, right?
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Dec 12, 2005, 11:18 AM
 
Originally Posted by Tomchu
If a file is r-xr--r-- root/root, and you are su'ed as root, then you can still write to it simply because you are *root*, even though you don't have the "official" write flag. In vi/vim, rather than doing :w to write the file out, do :w! and it will force an overwrite.
thx; i will give that a shot (using :w!). if i were to use 'wq!' it will not have the same effect as 'w!' right?

su and sudo will give me the same rights, right?
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
Grizzled Veteran
Join Date: Apr 2002
Location: case.edu
Status: Offline
Reply With Quote
Dec 12, 2005, 11:50 AM
 
Originally Posted by zanyterp
thx; i will give that a shot (using :w!). if i were to use 'wq!' it will not have the same effect as 'w!' right?
:wq! is equivalent to :w! :q, IIRC.

Originally Posted by zanyterp
su and sudo will give me the same rights, right?
Generally, yes.

pb 1440x960 | 1.67, 1.5, 128, 80 | leopard
     
Mac Enthusiast
Join Date: Apr 2003
Location: manticore or people's republic of haven
Status: Offline
Reply With Quote
Dec 12, 2005, 11:52 AM
 
thanks Tesseract.

got it to work on 10.4. before posting this, i had searched for the same thing and found mentions of a work-around/trick that needs to be done in 10.3.x? is that right? is this documented somewhere (i looked and couldn't find it in the forum)

thx!
some people are like slinkys: they don't do much, but are fun to push down stairs.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:05 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2