Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-31-2003, 03:20 PM   #1
Senior Member
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
/etc/hosts File

Big question here. I own the domain name In my /etc/hosts file I have: localhost

I don't even know if this is right but my webserver works. Anyway, could I put in a line like:

and then people could ssh into

I see people who have machine names like "the_matrix" and "lin-serv". When I boot up the GUI logon says "Welcome to" Can I change my computers name.

Yes I know this is extremly NOOBISH but thats why I put it here. I missed this part of Linux class.
Old 01-31-2003, 03:56 PM   #2
LQ Newbie
Registered: Jan 2003
Posts: 15

Rep: Reputation: 0
I believe the /etc/hosts file is for you own local machine only.

I don't think it involves any of the outside world.

I use it for DNS'ing local ips.
Lets say you have a computer beside you on the LAN.
It's IP is

You can put: computerbesideme your hosts file.

then, you can ssh/ftp/ping/telnet computerbesideme

and it will use

Old 01-31-2003, 03:56 PM   #3
Registered: Nov 2002
Location: Chicago, IL
Distribution: Rasbian, Debian, Gentoo, RHEL
Posts: 65

Rep: Reputation: 21
The actual hostname of your box should be some kind of name, for example let's assume it is anubis. Then the FQDN would be:
and the hostname would be:

Your /etc/hosts should have: anubis
where the ip address is available on the outside. should be an alias to which should be handled by your specific nameserver.

As for ssh-ing to the box, the only requirement is that you have the ssh port 22 enabled. Then all you need to do is ssh to ANY name that resolves to your address. you can even ssh directly to the ip address if you want to.
Old 01-31-2003, 04:13 PM   #4
Senior Member
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Original Poster
Rep: Reputation: 57
Okay so here is my situation. I purchased the address from I have it configured there to resolve to

Are you saying that I could change my /etc/hosts file to look like this: anubis

no localhost right? If I change this nothing will happen to right?

Old 01-31-2003, 05:06 PM   #5
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
You would still want localhost

to be in there.

Simply put, the /etc/hosts file is so YOUR machine will override the DNS settings of the internet. (VERY simply put, and somewhat erroneous, but works in the context of this situation.)

What exactly is it you are trying to accomplish with this?

The DNS server that is managing will handle all of the resolving for the rest of the world.
Old 01-31-2003, 07:17 PM   #6
Senior Member
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Just to confuse issues more.... I have a FQDN that resolves to a DHCP IP address, using a free service on some DNS...

What do I put in /etc/hosts for my IP?
Old 01-31-2003, 09:05 PM   #7
LQ Newbie
Registered: Jan 2003
Posts: 15

Rep: Reputation: 0
if your FQDN is already DNS'd on a DNS server, you don't need to put anything in the /etc/hosts file.

that file is only for DNS'ing things on your local computer only.

It is normally not used.

Old 02-01-2003, 01:04 AM   #8
Senior Member
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 49
The /etc/hosts file is basically so that your machine doesn't have
to look for a DNS server for the machine names that are in the
hosts file. For example, if I knew that Crashed_Again's IP
address was and I didn't want to do name resolution
every time I connect to that machine, I could put a line in my
/etc/hosts file like so: crash crashed_again
Or what ever other alia I wanted for it.
My /etc/hosts file contains all the hostnames from my work so
that when I need to connect to work I can use a short alias for
those machines, and it doesn't have to go through my ISP's slow
DNS server, it just connects to a specific IP address.
The /etc/hosts file is almost completely useless for connecting to
the machine it exists on. . . Use or $HOSTNAME localhost.


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
hosts file? milesstandish Red Hat 2 11-02-2004 11:57 PM
PB with /etc/hosts file(s) ptreves Linux - Networking 0 09-10-2004 07:39 PM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 05:33 PM
/etc/hosts file plexi100 Linux - Newbie 4 10-16-2003 06:03 PM
Hosts.allow file skopje909 Linux - Security 3 11-16-2001 10:49 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:11 PM.

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