Modify hosts in mac system
I mentioned how to modify the hosts on the Android phone. It is necessary to talk about how to modify the hosts on the mac system. Summary:
1. directly modify the vi editor.
Open the terminal (Application-utility) and run: sudo vi etc/hosts. on the screen, you will be prompted to enter the password (no characters will be displayed when you enter the password, or even * will not be displayed. after entering the password, press Enter ), open the hosts file and press the I key to enter the insert mode (which can be understood as the edit mode). Then, edit the file as needed. After editing, Press ESC to exit the insert mode, then press: wq + enter to save and exit.
2. Modify it directly in the graphic interface.
Open the Finder, and then click "go to" in the menu bar to go To the folder (or press the shortcut key Shift + Command + G), enter/private in the path, right-click the etc folder, and choose "show Introduction, find "share and permission" at the bottom of the folder introduction window and change the everyone permission to "read and write". If you find that the permission cannot be modified, unlock the lock in the lower right corner to modify the lock. After modifying the permissions of the etc folder, go to the etc folder and modify the permission for the hosts file (also everyone reading and writing). After the modification, you can right-click the hosts file, open and edit the file through text editing. After modifying and saving the file, remember to restore the permissions of the file and the etc folder.
3. Another graphic interface modification method.
Go to the http://code.google.com/p/gmask/ to download the Gas Mask. After installation, a gas mask icon is displayed on the menu bar. Click Show Editor to open the Editor. The password should be required for the first time (no prompt will be prompted later ). Then you can directly modify the settings and click Save.
4. cat command.
This method is suitable when you want to add some content to the Hosts file. First, you need to add the content to the Hosts as an example. Start the terminal and run the following two Commands: sudo-s cat ~ /123.txt>>/etc/hosts ~ The symbol represents the user directory of the current user in Mac and even all Unix and Linux systems. It represents the current directory. This time, you should understand why the above command is ~ /123.txt.
4. Use the nano editor to modify the settings.
The nano editor is easier to use than vi, but it is not powerful and does not seem to be popular. Run sudo nano/etc/hosts on the terminal, enter the password, open the hosts file, and edit the file as needed. After editing, press ctrl + o to save the file, when File Name to Write:/etc/hosts is displayed, press enter to confirm and press ctrl + x to exit.