How to immediately apply changes to the hosts file in CentOS 7?

To immediately apply changes to the hosts file, you can take the following actions:

  1. Open the terminal or command prompt window.
  2. Open the hosts file with a text editor (such as vi or nano) as an administrator. For example, you can run the following command using the vi editor:
sudo vi /etc/hosts
  1. Modify the content as needed in the open hosts file.
  2. Save and close the file. In the vi editor, you can press the Esc key, then type :wq to save and exit.
  3. Refresh the network configuration in order for the modifications to take effect. Run the following command:
sudo systemctl restart network

Your changes should now be effective immediately. You can try using the modified hosts file for network connections or access.

bannerAds