hosts(5)
๐ hosts(5) โ or, the manual page for your fave little address book ๐
okay bestie, pull up a chair, we're reading the File Formats Manual entry for hosts. it's giving "small file, huge main character energy" and i am obsessed. โจ
๐ NAME ๐
hosts โ static table lookup for hostnames
like. it's the og contacts list. no cloud sync. no drama. just vibes and IPs. ๐
๐ฆ SYNOPSIS ๐ฆ
/etc/hosts
that's it. that's the whole synopsis. one file. iconic. ๐ซถ
๐ธ DESCRIPTION ๐ธ
okay so this page is describing the format of the /etc/hosts file, and ngl it is so simple in the best way. it's a plain text file that associates IP addresses with hostnames, one line per IP address. one line!! per IP!! we love a one-to-one relationship, no cap. ๐
for each host, you want a single line chillin' there with this info:
IP_address canonical_hostname [aliases...]
the IP_address can conform to either IPv4 or IPv6 โ it's flexible like that, she contains multitudes. ๐
fields of the entry are separated by any number of blanks and/or tab characters. yes, any number. go feral with the spacebar, she doesn't mind. โจ
text from a "#" character until the end of the line is a comment, and is ignored โ so drag your thoughts, bestie, the file will simply not read them. ๐
now, host names may contain only alphanumeric characters, minus signs ("-"), and periods ("."). and they must begin with an alphabetic character and end with an alphanumeric character. that's not a suggestion, that's the vibe check, and you will be passing it. ๐
optional aliases provide for name changes, alternate spellings, shorter hostnames, or generic hostnames (for example, localhost). aliases are basically nicknames and honestly? every host deserves a nickname. ๐ฅฐ
and if required, a host may have two separate entries in this file; one for each version of the Internet Protocol (IPv4 and IPv6). two entries, two protocols, one very well-organized queen. ๐
The Berkeley Internet Name Domain (BIND) Server implements the Internet name server for UNIX systems. it augments or replaces the /etc/hosts file or hostname lookup, and frees a host from relying on /etc/hosts being up to date and complete. so like, BIND is the friend who takes over planning the group trip so you don't have to keep the spreadsheet current. generous!! ๐ซถ
in modern systems, even though the host table has been superseded by DNS, it is still widely used for:
- bootstrapping โ most systems have a small host table containing the name and address information for important hosts on the local network. this is useful when DNS is not running, for example during system bootup. it's the "we don't have wifi yet but we still need to know each other's names" era. ๐
- NIS โ sites that use NIS use the host table as input to the NIS host database. even though NIS can be used with DNS, most NIS sites still use the host table with an entry for all local hosts as a backup. backup friend!! the one who screenshots the plans in case the group chat gets deleted. ๐ญ
- isolated nodes โ very small sites that are isolated from the network use the host table instead of DNS. if the local information rarely changes, and the network is not connected to the Internet, DNS offers little advantage. lowkey why would you invite DNS to a party it's not even attending. ๐
๐ FILES ๐
/etc/hostsโ the file. the whole file. the file of all time. โจ
๐ NOTES ๐
modifications to this file normally take effect immediately, except in cases where the file is cached by applications. so like, usually instant, but some apps are out here holding onto old screenshots of your profile pic. ๐ซ
๐ง Historical notes ๐ง
RFC 952 gave the original format for the host table, though it has since changed. glow-up era, honestly. ๐
Before the advent of DNS, the host table was the only way of resolving hostnames on the fledgling Internet. the only way. the pressure?? ๐ญ indeed, this file could be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes were often required to bring it up to date regarding unofficial aliases and/or unknown hosts. so you'd get the official version and then immediately start remixing it โ very "i took the template and made it mine." ๐
The NIC no longer maintains the hosts.txt files, though looking around at the time of writing (circa 2000), there are historical hosts.txt files on the WWW. I just found three, from 92, 94, and 95. okay but the fact that the man page author is just casually telling us about their afternoon is so real of them. finding three ancient hosts.txt files like they're thrifting vintage. iconic behavior, no notes. ๐
๐ EXAMPLES ๐
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 localhost
# 127.0.1.1 is often used for the FQDN of the machine
127.0.1.1 thishost.example.org thishost
192.168.1.10 foo.example.org foo
192.168.1.13 bar.example.org bar
146.82.138.7 master.debian.org master
209.237.226.90 www.opensource.org
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
copy it exactly like that bestie, spacing and all. it ate. ๐ฅ
๐ซ SEE ALSO ๐ซ
hostname(1)resolver(3)host.conf(5)resolv.conf(5)resolver(5)hostname(7)named(8)- Internet RFC 952
reminder bestie: the vibes are immaculate but the facts are load-bearing. host names still start alphabetic and end alphanumeric, comments still start with #, and no amount of aesthetic saves a malformed entry. periodt. ๐
and that's the whole page, bestie!! stay slaying, stay resolvin' ๐ฆ
this has been brought to you by Linux man-pages 6.20, dated 2026-02-11, for hosts(5) โ mwah, xoxo, go edit your /etc/hosts responsibly ๐โจ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-2.0-or-later
- Copyright 2000, Manoj Srivastava <srivasta@debian.org>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms