What the heck is a host file and why in the world would you want to modify it?
A host file is the file on your computer that resolves domain names. For instance, we are very accustomed to going to websites by name. But this is a relatively new convenience. Back in the 80s, if you wanted to go to Google's network (let's imagine that Google existed back then), you'd have to enter the IP address. The IP address looks like "24.48.233.121." But we're human and don't identify companies or people by number. So now we use a convention called DNS- Domain Name System. It is the system that maps names with their IP address. So instead of typing 24.48.233.121, we can type in "www.google.com." What happens though, is that your computer goes to another computer (a DNS server) and asks that computer what the IP address is for the requested website. Once the IP address is known, it is very easy to work your way through the huge network called the internet to finally arrive at the computer that is hosting the webpage that you are looking for.
By the way, a webpage is just a file on a computer and a website is a collection of files that are related. A web browser merely "renders" the file's contents and displays it within the web client. Different web clients render pages a little differently which is why the same site may look a little different between Safari and Firefox.
Anyway, the two most popular reasons to modify your host file to either block known malicious sites or advertising sites, and to redirect your computer to a specific website upon requesting a page. Here's how you do it:
1. First, open Terminal. It is an application located in your Utilities folder.
2. Once Terminal is up and running, type "sudo pico /etc/hosts"
The "sudo" command invokes root user priveliges. The "pico" command is a common text editor that we are going to use to modify the file "hosts" that is located in the "etc" directory found on the root of the hard drive.
Terminal will then prompt you for the user's password. You must be logged in as an administrator to do this. You'll notice that as you type the password, nothing will appear on your screen. That is normal. Just press "Return" after you type in your password. You should then be taken to the Pico text editor. There is no mouse in Terminal so you must navigate with the keyboard only. Using your arrow keys, place the cursor after the first entry.
3. So once your cursor is blinking right after the "localhost" word, press return to enter a new line. You will then enter the IP address, then hit "Tab" and then enter the web address that you want resolved. Be sure to use the EXACT computer name.
4. When you are done, hit "Control-X" to exit. It will prompt you to save the file. Hit the key "Y" for yes. When it asks if you want to replace the existing file, again type "Y" for yes.
5. Then you can type "exit" and finally quit Terminal. You have just successfully modified your host file.
Be careful though, you can easily break your machine by doing something wrong. It may be a good idea to save a copy of the original file just in case you need to revert. In order for the changes to take effect, simply restart your machine. Logging out and back in again may work but a restart will surely work.
In Leopard, you could also just clear the DNS cache by typing "dscacheutil -flushcache" while in Terminal.
