Editing hosts file on a Mac

Pretty often, I have a need for editing my hosts file on my Mac. Mostly when i’m moving websites between webservers. This is not a problem on a windows machine, but on a Mac, you need to make a few more steps.
To editing the hosts file you need to do the following:
- Start Terminal.app (click on search and type terminal)
- Open the hosts file ($ sudo nano /private/etc/hosts) type your Password when promted
- Edit the content of the hosts file to suit your purpose
- Save the file by pressing “ctrl+o”
- Exit the editingprogram by pressing “ctrl+x”
- Reset the DNS-cache ($ dscacheutil -flushcache)
- Close terminal.app by typing “exit”