Macintosh(简称Mac)是苹果公司自1984年起开发的个人消费型计算机,包含如:iMac、Mac mini、Macbook Air、Macbook Pro、Macbook、Mac Pro等计算机。使用独立的macOS系统,最新的macOS系列基于NeXT系统开发,不支持兼容。是一套完备而独立的操作系统。
现在很多程序员都在用苹果笔记本电脑,初次体验发现mac系统和windows系统操作方式有很大不同,比如hosts文件打开方式,我们在配置IP地址和域名都会打开使用。那么mac系统的hosts文件在哪?怎么打开和编辑?下面跟随本经验一起来学习打开方法。
方法一:
1、首先开启一个文件夹,点击上方【前往】->【前往文件夹】。

2、输入“/private/etc/hosts”,点击【前往】。

3、自动开启“etc”文件夹,找到【hosts文件】,并将其拉到桌面上,也就是复制一份hosts文件到桌面上,这样才能修改桌面上的hosts文件。

4、“右键”桌面上hosts文件,选择【打开文件的应用程序】,使用【文字编辑】开启。

5、下面就可以开启编辑hosts文件。

6、编辑完后就可以把桌面上的hosts文件拉回到“/private/etc文件夹中”,会弹出询问框点击“确认”,并“取代”即可。

方法二:
1、在桌面左上角点击【放大镜】来“搜索”,输入“终”或者是“term”就会显示“终端机”,然后开启它。

2、开启后输入“sudo vi /private/etc/hosts”,并按下“Enter键”跳出要求你输入管理者密码,这个密码:就是开机时登入OS X时输入的密码,输入后直接按下“Enter键”即可,如果没有设定管理者密码用户开启的时候就输入“vi /private/etc/hosts”,肯恩贵出现权限不足的问题。

3、打开后就进入编辑器,可移动最后一行,按下键盘上的“o”键,会跳转到下一行的输入状态。这样就可以开始编辑hosts文件了。

4、编辑好hosts文件,按下键盘“Esc”按键,输入“:wq”将会自动保存,就可以结束编辑器。

5、这样一来就编辑完了hosts文件。

以上就是Mac电脑打开hosts文件的具体方法,只需要打开Finder应用,之后按下Shift+Command+G组合键,最后输入/etc/hosts回车即可找到hosts文件。