fbpx

Change your Host’s File on Linux, Mac, or Windows.

Change your Host’s File on Linux, Mac, or Windows.

How to change your Host’s file?

The hosts file is a plain text file that maps the domain names to the IP addresses. It is available in each of the operating systems like Linux, macOS, and Windows. However, in case you are editing the host’s file, you don’t need to make any changes to DNS settings.

Let’s discuss this with an example

  1. First, you write 10gbhosting.com into your browser tab and press enter.
  2. Then the domain is translated to the corresponding IP address.
  3. Then OS checks for host file associated 10gbhosting.com
  4. If no entry for this domain in the host’s file
  5. OS will go to the DNS servers to the particular domain names

Through this mechanism you can change DNS settings for domain just for the machine you are working

Why do you need to change your host’s file?

Changing your host’s file allows testing your site without requiring a DNS record. For instance, you are shifting your website or making sure that it is working before directing it to the new server. However, the host’s file could be used to restrict some specific sites from running on your PC.

To change your host’s file you need to build an entry for the domain to which you want the IP address to redirect given website.

For instance, adding the below the line in the host’s file will direct the records www. 10gbhosting and 10gbhosting to the IP 1.2.3.4:

1.2.3.4 www.10gbhosting.com 10gbhosting.com

Moving forward we will learn how to change your host’s file

How to change your host’s file on the following operating systems:

  • Windows 7, and older versions
  • Windows® 10, Windows 8,
  • Linux®
  • macOS® X versions 10.0 through 10.1.5
  • macOS X versions 10.6 through 10.12

Your computer will automatically send the domain to the specified IP address whenever you want to add information of the domain and save changes to the computer. However, make sure that, on completion of testing or migration, remove the changes immediately because it will be tricky to identify why your DNS is not behaving as assumed on different computers.

Windows

On Windows OS you need to use notepad or any text editor such as sublime, Atom, brackets, etc

Windows 10 or Windows 8

  • Open any text editor
  • Then go to File > Open.
  • Choose and open the following file: c:\Windows\System32\Drivers\etc\hosts
  • Do the preferred modifications to the file.
  • Click on File and then press Save.

Windows 7, and older versions

  • Open any text editor
  • Then go to File > Open.
  • Choose and open the following file: c:\Windows\System32\Drivers\etc\hosts
  • Do the preferred modifications to the file.
  • Click on File and then press Save.

Linux

  • Open a terminal window.
  • Type in the below command in your preferred text editor:
    sudo sensible-editor /etc/hosts
  • Enter your sudo password.
  • Skip over the current lines and make your changes at the bottom of the file. Add your latest mappings after the default mappings.
  • Do your modifications to the file.
  • Press Control-X and then enter y.

Mac OS X

  • Open a terminal window.
  • Open the /etc/hosts file by writing the below command in the terminal prompt:
    sudo nano /etc/hosts
  • Type your sudo password when asked.
  • Edit the /etc/hosts file.
  • Skip over the current lines and do your changes at the bottom of the file. Add your latest mappings after the default mappings.
  • Do your modifications to the file.
  • Press Control-X and then enter y.
  • You can get the outcomes of your modifications immediately by flushing your MacOS DNS cache:
    dscacheutil -flushcache

Hope with this article you go to learn how to change your host’s file on Linux, Mac or Windows

10gbhosting.com provides configurable and dedicated hosting services for eCommerce website owners that don’t want to lose their potential clients. Our dedicated hosting makes your website loading speed fast at an affordable price