I'd like to undo a sudo nano command

i used a sudo nano /etc/hosts command to set an artificial direct url.


Needless to say, it was a mistake. Is there a way to effectively say to the OS, "Go back to normal" so that my browsers go back to using DNS to locate and access the website?


The command I used was "sudo nano /etc/hosts www.websitename.com websitename.com xxx.xxx.xx.xx"


I have all the contents.


Your help will be a tremendous stress reducer!


Thanks

MacBook Pro 15″, macOS 10.13

Posted on Aug 24, 2022 5:33 PM

Reply
Question marked as ⚠️ Top-ranking reply

Posted on Aug 26, 2022 11:54 AM

The answer turned out to be amazingly simple, though devilishly difficult to learn.


In Terminal, use the command "sudo nano /private/etc/hosts" to show a list of commands outstanding in Terminal

Select the command that you need to "erase" (actually just make ineffective, as it remains)

Put a hashmark # at the beginning of the line

Use the ^O command to make it stick, ENTER or RETURN, and ^X to exit Terminal

You're done.


It took four days to find this and five minutes to execute it. The magic search term was "bypass in Mac Terminal"

5 replies
Sort By: 
Question marked as ⚠️ Top-ranking reply

Aug 26, 2022 11:54 AM in response to Bob Christensen

The answer turned out to be amazingly simple, though devilishly difficult to learn.


In Terminal, use the command "sudo nano /private/etc/hosts" to show a list of commands outstanding in Terminal

Select the command that you need to "erase" (actually just make ineffective, as it remains)

Put a hashmark # at the beginning of the line

Use the ^O command to make it stick, ENTER or RETURN, and ^X to exit Terminal

You're done.


It took four days to find this and five minutes to execute it. The magic search term was "bypass in Mac Terminal"

Reply

Aug 24, 2022 8:25 PM in response to Bob Christensen

Bob Christensen wrote:

i used a sudo nano /etc/hosts command to set an artificial direct url.

Needless to say, it was a mistake. Is there a way to effectively say to the OS, "Go back to normal" so that my browsers go back to using DNS to locate and access the website?

The command I used was "sudo nano /etc/hosts www.websitename.com websitename.com xxx.xxx.xx.xx"

I have all the contents.

Your help will be a tremendous stress reducer!

Thanks


see if this is it—


Fixing a hacked up /etc/hosts file

Fixing a hacked /etc/hosts file - Apple Community




Reply

Aug 25, 2022 6:43 AM in response to Bob Christensen

FYI, It is always best to make sure to have a backup of any files before you start to modify them so you can restore them if something goes wrong.


You do realize "nano" is a command line text editor? You can just launch nano with the file name for the file you want to edit which can allow you to delete those changes. The link also applies to macOS as far as how to use the "nano" editor.

https://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/


You also should not be using commands you have found on the Internet without understanding them and what they do. Plus you should always consider how you will recover if something goes wrong since there are no safety nets when using the command line.


Reply

Aug 25, 2022 10:46 AM in response to leroydouglas

Thanks, but your suggestion is focused almost entirely on a hack situation dealing with pirated goods. Our situation is different, where we have a command that points to the root of our website. In this case we want to remove that command or cause it to stop operating.

Reply

Aug 25, 2022 10:50 AM in response to HWTech

HWTech -- Thanks for your answer. Given our situation, what file name should we be looking for? Or is there a list of files from which we could choose?


FWIW, we weren't "finding commands on the internet;" we were following the suggestions of one of trusted security vendors. They blew it; it happens. We're not happy, but are focused on the fix at the moment.

Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

I'd like to undo a sudo nano command

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