Review your favorite Linux distribution.
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 07-02-2010, 04:34 PM   #1
Senior Member
Registered: Dec 2004
Posts: 1,025

Rep: Reputation: 67
what does /etc/hosts specifying in this particular line?

I'm doing a how-to to setup my debian server. It tells me to edit /etc/hosts to look like this (with different IPs and hostnames of course)
Code:       localhost.localdomain   localhost     server1
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
I'm curious about that second line. I know it'll be my actual server ip, but what does it specify? what is the 'server1' at the end of the line specifying? I *think* that 'server1' would be part of my bash prompt when i login, but am not sure. Is it used for anything else?
Old 07-02-2010, 04:49 PM   #2
LQ Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 271Reputation: 271Reputation: 271
Basically the names specified are the hostnames of the machine. You should typically specify the fully qualified domain name and the local host name (what is at the bash prompt). Note that you can assign more than one hostname to a particular IP address. This is how I cheat on some windows computers to block certain domains. I just redirect undesired sites to localhost ( Of course, it's easy enough to change, but frustrates the kids since they don't know what I did.

If you haven't blundered across it yet, is a good beginning debian server site.
Old 07-02-2010, 04:49 PM   #3
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
server1 is just an alias for

Your computer checks /etc/hosts before doing an DNS-lookup on a domain. If it finds an entry in /etc/hosts, it uses it. f.eks. 'ping server1' would be the same as 'ping' and the same as 'ping'. Well, not the same in that sense, but it would ping the same computer

/etc/hosts also has a historical background. In the old-days, before there were DNS-servers, this hosts file could be downloaded so you didn't have to use IP-addresses, but could use domains instead. After a while, it was inconvenient to use hosts due to updates and changes, and therefor they made a DNS-service.

Last edited by Dinithion; 07-02-2010 at 04:52 PM.
Old 07-02-2010, 04:51 PM   #4
harry edwards
Registered: Nov 2007
Location: Lincolnshire, UK
Distribution: CentOS, Fedora, and Suse
Posts: 365

Rep: Reputation: 48

Last edited by harry edwards; 07-02-2010 at 04:59 PM.
Old 07-02-2010, 06:17 PM   #5
LQ Newbie
Registered: Jun 2010
Distribution: RHEL 5.4,fedora 11, ubuntu 9.04
Posts: 8

Rep: Reputation: Disabled
/etc/hosts file contains data in this order,

IP-addr hostname alias

here server1 is alias name for
Old 07-02-2010, 08:26 PM   #6
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

As the previous posters said, the entries in "/etc/hosts" are just aliases for mapping IP addresses to a meaningful name.

One of these aliases is your "hostname" (and you can screw things up royally if you put in the WRONG IP address here) ...

... but /etc/hosts is NOT the place where you actually ASSIGN your PC's hostname. And that "assigned" hostname is the one in your prompt:

'Hope that helps .. PSM


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
warning: /etc/hosts.deny, line 20: missing ":" separator tkmsr Linux - Security 23 01-10-2015 11:01 AM
Verify /etc/hosts usage and round robin in /etc/hosts MikeyCarter Linux - Software 1 06-24-2008 12:20 PM
can't restrict sshd access through hosts.allow and hosts.deny but was working earlier farhan Linux - Security 4 04-18-2008 07:41 AM > Forums > Linux Forums > Linux - Newbie

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

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