How to Edit Hosts in Lion, Editing Hosts File in Lion

Home > Resource > How to Edit Hosts in Lion - Easy Way to Edit Hosts File in Mac OS X Lion

How to Edit Hosts in Lion?

Recently a friend who is newly using Mac OS X Lion's asked me how to modify the Hosts in the Lion system. He said that he had searched a lot of ways online but they are not useful. As long as he edit Hosts file in the Lion-based computer, the following prompt which said he was not the owner of the hosts file and had no permission to write it will appear.

have no permission to edit hosts file in mac os x lion

It is really a troublesome problem for the new users of Mac to solve this problem on the limits of authority. Therefore, here comes the tips to help you out of the dilemma. In the following text, I will share four methods to show you how to edit Hosts in Lion. All these four methods will not come with the access prompt. Besides editing hosts file in Lion, Mac OS X Snow Leopard (10.6) users also can use these methods to edit hosts file.

How to Edit Hosts in Lion with VI editor?

Step 1: Open the terminal (Applications - Utilities) and run "sudo vi /etc/hosts". Then the screen will prompt you to enter the password. What need to pay attention to is that there will not have any character and even * displayed when typing password in the right window. You only need press "Enter" key after completely entering the password.

Step 2: Then open the hosts file and press "i" to enter the insert mode, which you can also interpreted as edit mode. And then you can edit the file according to your need.

Step 3: After editing, you need first press the ESC key to exit the insert mode. Then you should press the keys ":wq" and "Enter" to save and exit.

This is the way which I always use. Linux users should be familiar VI editor which is a default built-in editor in Mac systems. However, for those Mac users who have used VI before, you really have to spend a little while to learn the basic use. Besides, the you'd better master the use of this tool if you want to use Mac more completely since VI editor is really a very powerful tool for Mac.

video converter ultimate for mac features

How to Edit Hosts in Lion with nano Editor?

This method is similar to the above one. Compared to the vi editor, this one is more easy-to-use. However, it has no strong functions and not as popular as the vi. You also need run "sudo nano /etc/hosts" in the terminal, enter the password, open the hosts file and then as you need to edit the file. Once you finish editing the hosts file, you should then press "ctrl + o" to save. And press Enter to confirm when "File Name to Write: / etc / hosts" notice appear. After that, you can press "ctrl + x" to exit.

How to Edit Hosts in Lion by Using the Cat Command to Merge Files?

This method is more suitable when you want to add some contents to the Hosts file content. The first thing you need to do is to save the contents which you want to add into the Hosts file in to a TXT file. (Highly recommend you to store this file directly in your user directory.) Here I will take the 123.txt which had been saved in the user directory as an example.

Start the terminal, and then run the following two commands: "sudo-s" and "cat ~/123.txt>>/etc/hosts". After that, you will find that the target content have been added to the hosts file flawlessly. By the way, the symbol "~" in the Mac or Unix and Linux-based systems represents the user directory of current user. The symbol "." means the current directory.

How to Edit Hosts in Lion Directly in the Graphical Interface?

Open the Finder, and click on the option "Go to -> Go to folder" from the menu bar (or click the shortcut "Shift + Command + G") to enter "/private" in the path. After that, you should right click on the "etc" folder to open the "Show Info" window. Find the "sharing & Permissions" at he bottom of the folder info window, and then change the permission to everyone into "read and write". If you find it can not be changed, you can then unlock the little lock at the lower right corner to get the permission changed.

After modifying the etc folder permissions, you should then into the etc folder to modify the permissions of the hosts file (change everyone to read and write again). After the modification, you can directly right click on the hosts file to open and edit it via "TextEdit". No permission would be prompted. Once you've modified and saved the file successfully, please don't forget to restore the permissions of the hosts file and "etc" folder.

Ok, that's all the methods I'd like to share with you. All these four solutions can be considered as the most simplest way to edit hosts file in Mac OS X Lion. If you have installed Lion and prepare to install it, then the tips on how to install Mac OS X Lion would give you a hand to get the system installed successfully. Besides, you can find more Mac tips and tricks from the DVD ripper resource center.

Keys: How to Edit Hosts in Lion, Editing Hosts File in Lion, Edit Lion Hosts, Edit Hosts File in Mac OS X Lion