Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vi /etc/hosts 3

Status
Not open for further replies.

telcomwork

Technical User
Mar 2, 2002
1,625
US
I'm trying to change a host file using vi but it tells me read only and I can't change anything. What's the right command to make changes?

Sorry for the newbie question!

Thanks!
 
You must be logged in as SUPERUSER to change /etc files.
You can use vi to edit that file just be sure to do a shift : and at the : type SET LIST this will display all characters.
 
I logged in a root.

Thank you I'll try that now!
 
I'm looged in as root.

I'll try that right now. Thank you!!
 
It change with prompts but still won't let me retype over any of the old config.
 
After you make the changes to the /etc/hosts file and you are ready to save your changes, try this sequence:

esc
:wq!

the wq! means write and quite; the ! forces the change. Your permissions on the /etc/hosts file probably don't have write permissions, so even root would have to do wq!

 
I can't even make the changes to get to try the :wq!

After pressing shift: what do I need to do next to make changes?

Thanks for all your help.
 
I jsut did a test using :wq! and it let me save. If I could only make changes now after using shift : I think I should be good to go.
 
To make the changes you will need hold the SHIFT KEY down and hit R this will overtype. Once you have amde the changes. Hold shift down and hit the : key. You should get a : in the lower left hand corner. At the : type wq!
The write or save the file and quit.
 
What do you mean specifically by "can't make changes" ?

If you type a letter it doesn't insert the letter?

Try:

esc
i

This i is for insert.

What is your TERM? (`echo $TERM` to find it) and try setting it to vt100 (`DISPLAY=vt100; export DISPLAY`)
 
I = insert
D = delete

Sorry just figured this out.
 
I really think you need a vi tutorial before you start messing with the /etc/hosts file!
 
Completed it last night successfuly but the tutorial isn't a bad idea. Thanks all!
 
At the same time this is a help forum and everyone is not going to know all, even the basics. I'm a telecom person, not a Unix Admin. I asked for basic help and with basic help from the others (which I thought this forum was all about) I was successful.

Now that I have time for a tutorial, I will do as you suggest but time and unreal expectations don't always warrent books, CDs, tutorials....

 
Sorry if you interpreted my post as dissing you (and I can see how you came to that conclusion), but I had no intention of doing so. I just know from bitter experience that messing with important files using vi can often end up causing more problems than it solves. Again, apologies, no offence intended.
 
NO problem I understand you're right. I need to learn more. I had to do this out of no where and all of you came up huge for me. Defintley taking your advice. I just felt like an idiot for asking after your post whcih is not your problem it's mine. Ego jsut got a little banged up :)

Seriously thanks for your help and recommendation. You're 100% right, it can go bab very quickly and I need to learn more.

Thansk again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top