Ubuntu如何修改hosts

首先创建一个文件,文件名hosts

touch hosts

用vscode或gedit打开编辑这个文件,写入如下内容:

127.0.0.1	localhost
#xxxxx为你的计算机名
127.0.1.1	xxxxxxx

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# 以下是你需要改的内容,ip+网址,以下为示例
39.105.88.167 www.github.com
112.32.5.63 www.baidu.com

最后将改好的hosts文件拷贝到/etc目录就可以了

sudo cp hosts /etc/

就这么简单

猜你喜欢

转载自blog.csdn.net/TU_Dresden/article/details/128531676