Mac is an acronym for Apple’s Macintosh systems and is generally used to refer to the operating systems of Macintosh. Simple controls and mouse gestures make the Mac OS more user friendly than other operating systems. Mac OS X comes with a great number of features that can easily be mastered. The Terminal is one such feature.
Terminal or the Terminal emulator is a text based program in Mac operating systems. Users can use the Terminal to manipulate the operating system using text commands. There may be many websites that you may want to block. In Windows, you can do with the Browser itself. In Mac, it can be done with the Terminal. However, it may appear to be a bit complicated.
With this tutorial, you will be able to block websites on Mac, by using text commands with the Terminal. You will get used to the technique once you do it yourself.
How to block Websites using Terminal
- Step 1: Click the Finder
- Step 2: Now from the Finder menu, select Applications
You will now be able to see a few folders.
- Step 3: Find the Utilities folder and click it. You will now see the Terminal application
- Step 4: Click Terminal. The Terminal window will now open up. Before starting, you have to backup the hosts.txt file. In this tutorial, we will back up the file in the desktop.
- Step 5: In the Terminal window, type ‘cp /etc/hosts ~/Desktop/hosts.txt’, without the quotes
- Step 6: Hit Enter. This will copy the hosts.txt file to your desktop as backup.
- Step 1: After copying the hosts.txt file, type ‘sudo pico /etc/hosts’, without the quotes
- Step 2: Hit Enter, upon hitting Enter, the system will prompt you for the Administrator password.
- Step 3: Provide your administrator password and then hit Enter. The /etc/hosts file will now appear. Now you have to go to the bottom of the file.
- Step 4: Use the arrow keys and navigate to the bottom of the file. When you have reached the bottom, you can add the website that you want to block.
- Step 5: Enter the IP address ‘127.0.0.1’, without the quotes, first
- Step 6: Just after the IP address, type the domain name of the website you want to block
For example, typing “127.0.0.1www.yahoo.com” (without the quotes of course) will block Yahoo on your Mac.
The theory is as follows. 127.0.0.1 is your Local Macintosh IP. If you type the website domain name following this IP, it will tell the computer that this is the address for that domain. A website domain and a computer can never have the same IP as this can confuse the system. Due to this command, the browser of the system won’t be able to differentiate that domain you have given, to a webpage. So technically, the website will be blocked.
- Step 7: Enter all the domains you want to block this way, with domains on separate lines
- Step 8: Once you are done entering the domains, press and hold Ctrl and then hit X.
You will now exit the terminal, and a Save prompt will appear.
- Step 9: Press Y to Save
To put the changes into effect
- Step 1: For Mac OS 10.4.X, type the following and hit Enter lookupd –flushcache
- Step 2: For Mac OS 10.5.X and higher versions, type the following and press Enter
sudo dscacheutil –flushcache
- Step 3: Click the Terminal menu and then click ‘Quit Terminal’ to exit
- Step 4: Open any browser and type in all the domain names to make sure they are blocked.
This is how you can block websites by modifying host file. The website will be blocked to all users of the system. This also applies to all browsers in the system. However, if you want to block sites by keywords, you require professional blocking tools.