• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How To Edit Hosts File on Your System

Written by Rahul, Updated on October 7, 2019

The hosts file is useful for mapping hostname or domain names with IP locally on the system. This file is available on each operating system and useful for mapping domains with IP addresses without making any DNS entry.

Sample Hosts File:

127.0.0.1   localhost.localdomain   localhost
::1         localhost6.localdomain6 localhost6

For example, if you are running a server on the public network and configured a website on that server. Now to access the website through the domain name, you must register a valid domain and point DNS records to that server. But using hosts file we can use any test domain name like example.com, www.example.com configure on server and map with IP in the hosts file, Using this we can access the site from the server without any domain registration and pointing DNS.

Edit Hosts File on Windows:

On Windows operating systems this file is available at following location with name “hosts”

 C:\Windows\System32\drivers\etc

Navigate to the above location in file explorer and edit “hosts” file in notepad and make any entry like below at end of the file.

127.0.0.1   localhost.localdomain   localhost
::1         localhost6.localdomain6 localhost6

192.168.1.100     example.com
192.168.1.100     www.example.com
10.10.0.11        site1.example.com site2.example.com

Save the file and close it. You have done the mapping between a domain name and IP locally on your system.

Edit Hosts File on Linux/Unix:

On Linux/Unix operating systems this file is generally available at following location

 /etc/hosts

Edit this file and make proper entry with hostname and ip address as below.

# vim /etc/hosts
127.0.0.1   localhost.localdomain   localhost
::1         localhost6.localdomain6 localhost6

192.168.1.100     example.com
192.168.1.100     www.example.com
10.10.0.11        site1.example.com site2.example.com

Save the file and close it. You have done the mapping between a domain name and IP locally on your system.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy