Step 1: Open terminal and type following command and press enter key.
sudo nano /private/etc/hosts
Step 2: edit file according to your requirement. make sure that after IP address gives a space.
step 3: Press control + o
press control + x
then terminal will be exit.
To update changes clear the cache by typing following command in terminal.
check website in browser.
watch full video steps in youtube.