How to modify hosts file in MAC?

0 votes
25 views
asked Feb 13 by Hitesh Garg (352 points)  

I want to add the name to the host file for an IP. How to do that in a MAC system using the command line terminal.

1 Answer

0 votes
answered Feb 13 by Hitesh Garg (352 points)  
 
Best answer

Use the following steps -

  • Launch Terminal, type sudo nano /private/etc/hosts and press Return. You’ll need to also enter your admin password to execute it, as with all sudo commands.
  • You will now have the hosts file open in the Nano editor. Use the arrow keys on your keyboard, to navigate and edit the file.
  • Go to the bottom of the file and add the desired IP followed by the host name (or domain name). Save the file and you are all set.
  • Use your Web browser to test the changes and flush the cache with dscacheutil -flushcache if they still haven’t taken into effect.

For complete reference on windows, MAC and Linux use the following link.
How to edit hosts file

194 questions

41 answers

3 comments

929 users

Most popular tags

java python python3 oracle database java-8 sql-server python2 oracle11g git oracle-12g command-line maven sql-server-2012 sql input array list temovate clobetasol fenitoina dilantin pletal cilostazol java的 angular javascripts git-branch intellij-idea hashmap collection file-io io extra super avana avanafil dapoxetina nortriptyline pamelor hydrea hydroxyurea betametasona clotrimazol lotrisone clomiphene clomid acticin permetrina bimatoprost bimatoprosta tamsulosina flomax sildenafil hasco viagra dafilar tadalafil atarax hydroxyzine zestoretic lisinopril hydrochlorothiazide perindopril apo-perindox glibenclamida micronase neoral ciclosporin tadalafil vivala http: www.bosen-metal.com http: www.acontactor.com loxapine loxitane zyban bupropion diltiazem hcl cardizem fincar finasteride dapoxetina priligy gemfibrozilo lopid sinemet carbidopa levodopa tinidazol tinidazole bimatoprost careprost cotrimoxazole ikaprim furosemid lasix diltiazem diltiazem ortho tri-cyclen norgestimate ethinylestradiol verapamilo isoptin sr tadalafil re-zoom clorambucilo leukeran hydrochlorothiazide microzide theo-24 sr theophylline loratadin claritin viramune nevirapina requip ropinirole eulexin flutamid kemadrin prociclidina prilosec omeprazole isosorbide imdur naltrexone revia wellbutrin xr bupropion hippigra sildenafil citrate anaprox naproxeno lozol indapamid flibanserin flibanserine naproxenum natricum naproxen ibuprofen motrin tadalafil kwiklis lincocin lincomycin loxitane loxapin lexapro escitalopram sildenafil citrate vigorama pioglitazone actos filda tadalafil lasix furosemide dutasteride avodart phenergan promethazine minocin minociclina minocycline hydrochloride minocin prograf tacrolimus oneaid tadalafil sporanox itraconazol elavil amitriptyline sildenafil citrate refren ampicillin principen daclatasvir daklinza
Welcome to Codingeek Q&A, where you can ask questions and receive answers from other members of the community.
...