LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2005, 11:56 AM   #1
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Rep: Reputation: 15
edit /etc/hosts


I need to add a line to /etc/hosts, but don't know how.

I'm using Mandriva 10.1.

I can open a terminal emulator.

I typed in: vi etc/hosts

I got a very scary screen that I didn't dare do anything in. I have the line all ready to paste in, but where? how?

Haaaaaaalp!

Thanks.
 
Old 09-19-2005, 12:01 PM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You might want to look at a tutorial for vi, like this one.

Also, are you trying to edit that file as your normal user? If so, you'll probably get an error about the file being read-only (or something similar). So, try editing it as root (type su, followed by your root password and then execute as you did).
 
Old 09-19-2005, 12:15 PM   #3
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Thank you! No, I was doing the root thingy, having entered my password.

I went to the tutorial site you suggested and discovered that vi isn't what I want (I think?). That seems to start a whole new file, and I want to edit an existing file (I think?). By edit, I'm assuming I mean "add a line at the end to"--but I could be wrong about this, too. I've been wrong 9 times already today, so one more will hardly be noticed.

Perhaps you could tell me how to edit the pre-existing file.

Sorry to be so dim-witted.
 
Old 09-19-2005, 12:19 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Actually, I don't really use vi so am not sure. One suggestion though is to use nano or pico instead of vi, as they are really easy to use (at least, easier than vi). You probably have one or the other on your system and just run it the same way as with vi, eg. nano /etc/hosts.
 
Old 09-19-2005, 12:25 PM   #5
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
No, I already tried nano and pico. I don't have those, apparently. Should I download one or the other?
 
Old 09-19-2005, 12:27 PM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Can do if you want. Are you using X Windows? You may have gedit or kate.. try those too.
 
Old 09-19-2005, 12:29 PM   #7
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Turns out nano and pico aren't available for Mandriva. But I do have Kate! OK, now what?
 
Old 09-19-2005, 12:30 PM   #8
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Forgot to mention, have no idea what X windows is, so assume I'm not using it.
 
Old 09-19-2005, 12:34 PM   #9
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You're not using a GUI right now then? If not, then type startx at the prompt to load the GUI. After that, open a terminal, change to root and then type "kate /etc/hosts" and edit the file. IIRC, kate is fairly intuitive (I don't have a Linux box right now so can't check). If you ARE using a GUI already (I assumed you were, cos you said you opened a terminal emulator) then just skip everything, except the last bit.
 
Old 09-19-2005, 12:39 PM   #10
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Oh, dear, yes, of course I'm using GUI. Sorry, I'm such a CCI.

Here's the one and only line that kate spits out:

127.0.0.1 localhost

Should I append my new line to that?
 
Old 09-19-2005, 12:46 PM   #11
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Now I've done it. Here's what happened when I added the line, saved and quit kate. On the root console I got:

Mutex destroy failure blah blah
ICE default 10 error handler doing an exit blah blah

Have I thoroughly screwed it up now?
 
Old 09-19-2005, 12:51 PM   #12
ninapratt
LQ Newbie
 
Registered: Jun 2005
Location: Rhode Island within spitting distance of the water
Distribution: Mandriva Discovery 10.1
Posts: 21

Original Poster
Rep: Reputation: 15
Aha! Whatever I did seems to have worked! Thank you for your kind and patient help.

Nina
 
Old 09-19-2005, 01:14 PM   #13
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,085

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
ninapratt,
Looks like you have solved your own problem - well done!
Quote:
Mutex destroy failure blah blah
ICE default 10 error handler doing an exit blah blah
Do not worry about those error messages, they are of no consequence (but i wish someone would fix them!)

vi probably started on a new file for you because you typed "vi etc/hosts" and not "vi /etc/hosts" - there is a difference! You should probably learn a little vi because one day you will need it big time! Eg when you cannot get to the GUI and you are left with a text terminal only.

You only need to know about 4 vi commands:

The arrow keys move around the file.
i start Insert mode, so you can type/delete text
[ESC]:wq writes the file and quits
[ESC]:q! quits without making any changes

Practice on a simple (non-system) file until you are happy that you can do the basics.
Have fun with linux.
 
Old 09-19-2005, 02:30 PM   #14
Orkie
Member
 
Registered: Mar 2005
Distribution: Breezy Badger
Posts: 248

Rep: Reputation: 30
Quote:
Originally posted by ninapratt
Forgot to mention, have no idea what X windows is, so assume I'm not using it.
X Windows is what most Linux GUIs run through - it is what connects the screen, mouse and keyboard together.
 
Old 09-19-2005, 02:32 PM   #15
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally posted by tredegar
Do not worry about those error messages, they are of no consequence (but i wish someone would fix them!)
That's good to know.. I've been getting them as well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there an easier way to edit /etc/hosts? n3rds3x Linux - General 4 05-05-2005 06:42 AM
hosts.allow & hosts.deny question... jonc Linux - Security 9 03-05-2005 10:41 PM
Cannot edit hosts file k3nn0n Fedora 3 05-26-2004 12:00 PM
Adding shell commands to hosts.deny and hosts.allow ridertech Linux - Security 3 12-29-2003 04:52 PM
error on start up---edit /etc/hosts emacin777 Linux - Networking 1 09-03-2003 01:10 PM


All times are GMT -5. The time now is 05:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration