Need help? Chat now!

Hostwinds Tutorials

Search results for:


Table of Contents


Windows 7
Windows 10
Linux/Mac OSX
Are There Other Options?
Use Your Current cPanel In The URL
Use Hosts.cx

How To Edit A Hosts File

Tags: Windows,  Linux 

Windows 7
Windows 10
Linux/Mac OSX
Are There Other Options?
Use Your Current cPanel In The URL
Use Hosts.cx

You may find that you're asked to or need to edit your hosts file in some instances. At this point, you may be wondering what a host file is? A hosts file is a plain text file that is used to link hostnames to IP addresses. This article will cover how to locate and edit your hosts file on Windows (7, 10), Linux, and Mac OSX.

Windows 7

To modify your hosts file in Windows 7, you'll need to open the hosts file up in Notepad with administrative permissions. This can be done by clicking the Start icon and searching for notepad.

Once the results populate, right-click notepad and select Run as Administrator.

Once notepad is open, click on File, select Open, then enter in the following file path and click Open:

C:\Windows\System32\drivers\etc\hosts

With the file open, you can make the necessary edits. When making these edits, you'll need to ensure that you follow the IP address format then domain name. For example, we will edit tutorials.hostwinds.com so that it loads from 192.168.1.1 like so:

192.168.1.1 tutorials.hostwinds.com

Once you have completed making your edits, sure to save the file.

Windows 10

To modify your hosts file in Windows 10, you'll need to open the hosts file up in Notepad with administrative permissions, similarly to editing this file in Windows 7. This can be done by clicking the Search bar and searching for notepad.

Right-click notepad from the results and select Run as Administrator.

With notepad now open, click on the File option, select Open using the following path and finally, Click the Open button.

C:\Windows\System32\drivers\etc\hosts

Just like in Windows 7, with the file open, you can make the necessary edits. When making these edits, you'll need to ensure that you follow the IP address format then the domain name. For example, we will edit tutorials.hostwinds.com so that it loads from 192.168.1.1 like so:

192.168.1.1 tutorials.hostwinds.com

Once you have completed making your edits, save the file by clicking File then selecting Save.

Linux/Mac OSX

In most Linux distros you can edit the hosts file directly from SSH or the terminal using your favorite text editor. Likewise, in OSX, you can do the same thing. This article will be using CentOS 7 and the Nano text editor for Linux and vim for OSX. To begin editing the hosts file, issue the following command in Linux.

nano /etc/hosts

As a non-root user in Linux, you'd use:

sudo nano /etc/hosts

In OSX, you'd use the following:

sudo vim /etc/hosts

The hosts file should now be open, and you can begin making your necessary edits. When making these edits, you'll need to ensure that you follow the IP address format then the domain name. For example, we will edit tutorials.hostwinds.com so that it loads from 192.168.1.1 like so:

192.168.1.1 tutorials.hostwinds.com

Save the file in Nano by pressing CTRL+O, then Enter, and finally CTRL+X.

In Vim you'd press the Esc key followed by the colon (:) key and then type wq! in the terminal.

Are There Other Options?

Typically host files are created and edited to review your current web management tool populates before changing your DNS to your new host.  Although host files can help with this, there are other available, possibly easier options, to achieve the same goal.

Use Your Current cPanel In The URL

You can use the following, provided you have a cPanel account, by utilizing your dedicated IP and cPanel username as the following in the URL, replacing "xxx.xxx.xxx.104" with your IP and "cpanelusername: with your username provided:

xxx.xxx.xxx.104/~cpanelusername

Typing the following into your URL will show you whatever is within your CPanel >> File Manager >> public_html (root) folder.  Furthermore, if you need to examine deeper folders or files, you would extend the "cpanelusername" with the directory you wish to review, like the following:

xxx.xxx.xxx.104/~cpanelusername/nextfolder/thisfile

Use Hosts.cx

When examining your CPanel like above, one issue is certain plugins may or may not apply or function properly until fully utilized and hosted as intended.  Using https://hosts.cx/ is a great tool to fully examine what your web management tool will render when fully pointed to.  Put in your provided dedicated IP and website name within your web management tool, and it will show you what would display if already fully hosted.

Written by Michael Brower  /  June 22, 2017