How to modify the Hosts file on Mac

Every time I have to query how to change the Hosts file, I’d better record it! ! ! !

1. Modify terminal commands

(1) Open the terminal and enter the command line :

sudo vi /etc/hosts

(2) After entering the local password, the hosts file will be automatically opened.

  • Enter i (insert) on the keyboard. After the modification is completed, press the esc key to exit the insert page.
  • Save and exit: enter :wq or :wq!, then enter 
  • Exit without saving: enter q and! key, then enter key

2. Modify the hosts file (the first one is commonly used)

  • Method 1 (I don’t know what happened but it failed after restarting and needs to be added again)

(1) Open Finder, use the shortcut keys Shift+Command+G to find the file, enter /etc/hosts, and click Go

 

(2) Copy the hosts file to the desktop and replace the original hosts file after the modification is successful.

  • Method Two

(1) Open Finder, use the shortcut key Shift+Command+G to find the file, enter /private to go

 

 (2) After finding the etc file, select Show Introduction

 

 (3) Find the sharing and permissions, change everyone's permissions to read and write, save and modify the hosts file, remember to change the permissions back after the modification is successful!

 

Guess you like

Origin blog.csdn.net/D2EF68A85BC/article/details/125779557