Mondoze Knowledge Base

Search our articles or browse by category below

Linux VPS Hosting Tips On Editing Host File In 3 Steps

Last modified: October 7, 2022
You are here:
Estimated reading time: 1 min

Regardless of the operating system, such as Linux VPS hosting, or Windows VPS hosting, a system’s host file is essential for the operating system to map the hostnames to the IP addresses. For hosting users who are switching to another provider, it is possible to check if their website works properly before moving their domain to another server by editing the host files.

This will be a guide on how to edit the host file in your Linux OS via terminal. The steps to edit the host file are as followed.

Step 1: Open terminal

For Linux operating system, the terminal is able to easily access the system. While some of the Linux may vary with others, the logic behind it is usually the same.

To open the terminal, go through the “Application”, then “Utilities” page and you can find the terminal application there. Another easy way of doing it is to right-click on the desktop and pick the option “Open Terminal”.

Step 2: Locate and open the file

To locate the host file in your system, use the following command to achieve it.

sudo vim /etc/hosts

Note that the command above, where it says “vim”, is for the text editor called “Vim”. If you are using any other text editor, you may replace the command with the vim command. After running the command, the system will identify if the user is an administrator by prompting the user to enter the password.

Step 3: Modify Hosts File

Similar to the way of editing the host file, just enter the format as shown below for every domain needed to be tested. Do note that the test only works on the local machine, similar to the case of the Windows VPS hosting.

{IP Address} {exampledomain.com} {www.exampledomain.com}

Similar to Windows, add a new line for each domain tested and click “Y” when prompted to save changes. Revert the file back to its original version once the tests were done.

Was this article helpful?
Dislike 0
Views: 71