#On Linux, you can modify the hosts file through the command line or through the graphical interface. We will introduce it in sequence, first through the command line, taking the CentOS/RHEL distribution as an example.
The hosts file of this version is in the /etc directory. The command to open it with the editor is: vim /etc/hosts
After the addition is completed, press :wq to save. The hosts file command line form is modified.
Modify the Hosts file through the graphical interface. In this case, you must log in as the root user, otherwise you will be prompted to enter the root password when making modifications. After logging in, click application in the upper left corner of the page, then click favorite, then click files to open the file manager
Click computers on the left side of the file manager, and then the system will be displayed on the right All directories in the directory, find the /etc/ directory on the right, double-click to open it, and pull down to find the hosts file. Double-click to open the hosts file, edit the content you need directly like in Notepad, and click the save button in the upper right corner after editing. Save the content. At this point, the hosts file has been modified.The above is the detailed content of How to modify the linux hosts file. For more information, please follow other related articles on the PHP Chinese website!