How to configure the hosts file in CentOS?
To configure the hosts file of CentOS, you can follow the steps below:
- Open the terminal window and log into the system as the root user.
- Open the file /etc/hosts using vi.
- The IP address 192.168.1.100 corresponds to example.com, and the IP address 192.168.1.101 corresponds to test.example.com.
- Save and close the file. In the vi editor, press the Esc key, then type “:wq”, and finally press Enter.
- Check the connectivity to example.com through the ping command.
Please note that modifying the hosts file may require root permission. Make sure to operate as the root user or use the sudo command for the relevant tasks.