Here’s an easy way to block annoying advertisement and malware sites using ‘/etc/hosts’ file.
First edit the /etc/hosts files using your favorite text editor :
sudo gedit /etc/hosts
Then, paste the list of ads/malware servers in the ‘hosts’ file. You can get the list from http://someonewhocares.org/hosts/ or by searching through Google.
Close the file, and Save. The change will take effect immediately after that. One of the side-effect from this modfication is that your web surfing experience would be significantly faster because your browser does not have to wait for the annoying advertisement to load.