Hosts File

Unfortunately, Safari does not currently allow you to customize the search engines available from the search bar. There are add-ons available that can help work around this, without needing to edit the Hosts file. You can find those here.
Alternatively, you can follow either of the procedures below, to work around Safari.
 
DuckDuckGo operates a server that can respond to Safari’s search requests directed at Yahoo, Google, or Bing, and send those to DuckDuckGo instead. To use it, you can either use an app to make the change, or edit your hosts file directly.
 

Method 1: Mac app

A third-party app which can set this up automatically for you is available here.
****Note that this app is not provided by DuckDuckGo.
 
After you use this app, selecting Yahoo in the Safari search bar will search DuckDuckGo instead. Likewise, if you set your default to Yahoo in Safari Preferences, your default will actually be DuckDuckGo.
 
If you change your mind, just open the app again to undo the changes.

The reason for switching Yahoo instead of Bing or Google is that Yahoo just affects the search.yahoo.com domain (you can still get to yahoo.com), whereas doing the same for Bing or Google would have to affect their whole domains using this method.
 

Method 2: Editing the hosts file

This method is intended only for advanced users.
 
Mac users: Open the Terminal app. This is in your Applications folder, in the Utilities folder.
 
Type this command:
 
sudo nano /etc/hosts

You will be asked for your password. Type it and press return. Note that nothing will appear in the window as you are typing; this is normal.
 
This starts the Nano text editor. Use the arrow keys to move to the end of the file, press return a few times, and add this line:
 
184.72.115.86 search.yahoo.com
 
Then save the file by pressing Control-O, and quit Nano by pressing Control-X.

Windows users:
 
Navigate to: c:\windows\system32\drivers\etc\hosts (this directory should be the same for XP/Vista/Win7). Right click on 'hosts' file > properties; uncheck 'read only'; click 'apply'. Then right click on 'hosts' > open with.. notepad.
 
Add the following line at the end of the file:

184.72.115.86 search.yahoo.com
 
Note that you need to have elevated privileges to be able to perform this. The easiest way to do that is to right click on the 'hosts' file again -> properties -> security -> Edit.... Then select Users and click the checkbox next to Full control, click OK, and then OK again.

Then:
 
Restart Safari after you do the above on your platform. From now on, selecting Yahoo in the Safari search bar will search DuckDuckGo instead. Likewise, if you set your default to Yahoo in Safari Preferences, your default will actually be DuckDuckGo.
 
You can use this same trick to replace Google or Bing in the Safari search bar; substitute one of these lines instead (there’s no need to use more than one):
 
184.72.115.86 www.google.com
184.72.115.86 www.bing.com
 
BIG WARNING: Using one of the two above lines will block all of Google or Bing, respectively: you will not be able to access Gmail, Google Maps, etc. This is probably not what you want. Since Yahoo Search is on a separate subdomain, using this trick with Yahoo does not have this downside (i.e., Yahoo Mail, Yahoo Maps, and the rest of Yahoo are not effected). For this reason, it’s recommended to use the Yahoo line.
 
To undo the changes, simply reverse the directions and remove the lines you added. Don't change anything else in the file.
 

Miscellany

Did you know? You can control-click any word in any app on Mac OS X and select ‘Search with...’, and it opens a search in your default Safari search engine (which you can set to DuckDuckGo!).
Show More Links