Four Methods for modifying Hosts under Mac OS X Lion

Source: Internet
Author: User


Four Methods for modifying Hosts under Mac OS x Lion: www.2cto.com a friend who just used Mac OS X Lion asked me how to modify the Hosts file in the system, if you search for the Hosts file on the internet, you will find the message "you are not the owner of the hosts file, so you are not authorized to write the file, it is troublesome to solve this permission problem. It is not easy for Mac users to understand. Therefore, with this tip, I will share four methods to modify the Hosts file in the Mac OS X Lion system. No permission prompt will appear for these four methods, mac OS X Snow Leopard (10.6) users can also use these methods. Www.2cto.com 1. Open the terminal (Application-utility) through the VI editor and run: on The sudo vi/etc/hosts screen, you will be prompted to enter the password (no character is displayed when you enter the password, or even * is not displayed, press enter after the password is entered ), 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, press: wq + press enter to save and exit. Remember to enter the colon in English. This is a method that I have been using. The VI editor should be familiar to users who often use Linux, and is built into the Mac system by default. However, it takes a while for users who have never used VI to learn how to use it. In addition, the VI editor is a very powerful tool. If you want to have a good Mac, you 'd better master the use of this tool. 2. Using the nano editor is similar to the above method. This editor is easier to use than vi, but it is not powerful and does not seem to be popular. Run sudo nano/etc/hosts in the terminal by entering the password, opening the hosts file, and editing the file as needed, after editing, press ctrl + o to save. When File Name to Write:/etc/hosts is displayed, press enter to confirm and press ctrl + x to exit. 3. Use the cat command to merge files. 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 by the way ,~ 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. Open the Finder directly in the graphic interface, click go in the menu bar to go To the folder (or press the shortcut key Shift + Command + G), and enter/private in the path, right-click the etc folder and choose "show Introduction". In the folder introduction window, find "share and permission" and change the everyone permission to "read and write ", if you find that the lock cannot be modified, unlock the lock in the lower right corner and 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. In the end, the methods for modifying Hosts in the Lion system shared in this Article do not show any prompts that you do not have the permission to modify the file. This prompt is actually a high performance of Lion Security, the above methods can be used in the 10.6 system. At least the simplest methods for modifying Hosts files in the Lion system are counted. In addition, you can see that the above three methods all need to be operated on the terminal. for users who have just used Mac and have not played Linux, it may be very troublesome. In fact, the terminal is very simple, there are just a few commands that are very powerful and can implement many unexpected functions. Therefore, for those who have just used Mac, do not be intimidated by command line operations such as terminal operations. Basically, you only need to copy the command, paste it, and press Enter, what's the problem?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.