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:
- Open the terminal or command prompt window.
- 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
- Modify the content as needed in the open hosts file.
- Save and close the file. In the vi editor, you can press the Esc key, then type :wq to save and exit.
- 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.