...
Line
Skip to main content
< All Topics
Print

How to Edit Linux Hosts File?

Step 1: Backup Old Hosts File The hosts file can contain critical network configuration parameters. Execute the following command to ensure you have a backup copy of the original file before making any changes:

If something goes wrong and you want to restore the previous hosts configuration, type the mv command below:

Step 2: Open Hosts File

Open the host file using a text editor. This tutorial uses nano:

The file may already contain some default system IPv4 and IPv6 mappings. IPv4 mappings are at the top of the file.

Step 3: Edit Hosts File

Adding an IP address and domain pair to the Hosts file in Linux.Place your mappings in the corresponding category. Use the following syntax:

To set up aliases for the same IP address, put them in the same line but separate the hostnames with a space:

When you finish, save the file and exit.

Credit :  How to Edit Hosts File on Linux | phoenixNAP KB

Messenger
Seraphinite AcceleratorOptimized by Seraphinite Accelerator
Turns on site high speed to be attractive for people and search engines.