Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Edit hosts file in Catalina

Hi.

After I upgraded to Catalina, I can no longer edit the hosts file. It will only let me duplicate it, which is of no good.

When I try to su administrator in terminal, it will not accept my password.

How can I edit the file in my text editor of choice?

I am the owner and only user of my computer, I should be able to edit the file if I please. :-)

MacBook Pro 15", macOS 10.15

Posted on Oct 31, 2019 1:43 AM

Reply

Similar questions

5 replies

Oct 31, 2019 3:52 AM in response to Eau Rouge

I use this quite often because I sometimes need access to servers by name which are not in our internal DNS.

I can edit the hosts file as usual, the only thing to do is to open the terminal app, and issue the su command and specify the password of the root user. If you are the owner of the Mac, and your account is an administrator then the password of root might be the same as that of your account. If the root account is not enabled then enable it, see https://support.apple.com/en-us/HT204012.

Now you can use vi to edit the hosts file.

Oct 31, 2019 2:57 AM in response to vayu

Ok I have had a look at this, open the Hosts file, duplicate it, alter it as you want, save it to the Desktop

as Hosts copy.txt. Control click on the original Hosts file, and Move To Bin. Do not Empty The Bin, instead

move the original file to a folder called Original Hosts File.

Now go to the Hosts copy and remove copy and the .txt extension from the title and move it back to the

original location of Hosts file.

Restart your Mac.


Before you do this make sure you have made back up of your Mac. And keep the original Hosts file safe.

Nov 13, 2019 2:23 AM in response to Eau Rouge

I've just edited the host files to block adverts in Catalina, I've only upgraded one of the older MacBookPro's before I go and "upgrade" the rest of the more important ones! It's easier in Terminal "sudo nano /etc/hosts"



One behaviour I have discovered is that whilst the adverts are blocked, the advert place holders are still being shown up in safari, this doesn't happen in Mojave and earlier, not sure why this is happening I will have to download some more browsers and look into it...


<append>


Yep it's a safari issue, opera renders websites completely advert free and reflows websites without "hole" where the adverts would once have been.

Edit hosts file in Catalina

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.