However, it’s wise to keep a backup of the file before you make any changes, in case anything goes wrong. Now you can edit the Hosts file as you wish. It is a good idea to redirect tee output to /dev/null when appending text. We can append to a file with sudo: cat myfile.txt sudo tee -a existingfile.txt > /dev/null. Verify that you just appended to a file as sudo with cat command: cat file1. Step 4: Hosts file is now open on the Nano text editor. Try: echo 'data' sudo tee -a file1 file2 fil3. Step 3: If the command line above is typed in correctly, Terminal would ask for the Admin password. Step 2: To open the Hosts file, type the following command: Open Utilities folder and it should be chronologically ordered. You can also click the search bar at the top of the Menu window and then type in terminal to search for it. You'll typically find Terminal in a bar on the left side of the Menu window. This is how you could edit a Hosts file on Mac OS X using terminal: To do so, click Menu, then find the Terminal app-which resembles a black box with a white '>' in it-and click on it. ![]() However, in case you want to edit the Hosts file to be using with unpublished web sites or blocking a domain, you need to know the respective IP addresses and/or the domain names. The app is already provided inside the Utilities folder, hence no additional download or purchase from app store would be required. However you can edit the hosts file thanks to the Nano editor. ![]() To edit a text file of this category, the best app on Mac OS platform is Terminal. So, for example, you’d type sudo vi /etc/fstab if you wanted to edit. Remember to use sudo if you want to edit a system file. The vi /path/to/file command also works if the file doesn’t exist yet Vi will create a new file and write it to the specified location when you save. Edit the Hosts File using Terminal & Nano EditorĪnother useful purpose is to block annoying adwares or a specific domain name without using any third party apps. Use the vi /path/to/file command to open an existing file with Vi. Before the website’s DNS goes online, the developer could just use the domain name and associate it with the Hosts file by editing it. Especially for website developers who would need to access publicly unavailable websites for testing purpose, could just utilize the Hosts file. There are few very practical uses of the Hosts file.
0 Comments
Leave a Reply. |