Method: 1. Use the "vi /etc/hosts" command to open the edit text mode of hosts; 2. Enter the command "i" to enter the edit mode, and use the "sudo vi /etc/hosts" command to force the file to be changed. Permissions; 3. Enter the password to modify the file content; 4. Use the "wq" command to save the modification results.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
How to modify the hosts file in Linux
To modify the hosts file, you need to modify the file /etc/hosts and then restart tomcat
Modify File /etc/hosts
Step 1:
Enter the command: vi /etc/hosts
Open the edit text mode of hosts
Step 2 :
Enter the command i
to enter the editing mode. At this time, you may be prompted: changing a “readonly” file attention
At this time, you can use the command to force change file permissions: sudo vi /etc/hosts
Enter the corresponding password, press Enter, enter the edit mode and modify the content to complete
Step 3:
Enter the command: :wq Save and exit
Step 4:
Enter the command: cat /etc/hosts to check whether the contents of the modified hosts file have been modified successfully
Related recommendations: "Linux Video Tutorial》
The above is the detailed content of How to modify the hosts file in linux. For more information, please follow other related articles on the PHP Chinese website!