(Mac) Mac上如何修改本地的hostname

前言

之前运行Spark的时候遇到一个问题. 由于本地hostname不对导致链接连不上. 将记录操作记录于此.


操作细节

Mac上配置Hostname主要包括2处.

  • /etc/hosts
localhost:~ sean$ ls /etc | grep ".*hosts.*"
hosts
hosts.equiv

可以看到就只有2个文件. 无hostname文件.

localhost:~ sean$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
  • hostname命令查看
localhost:~ sean$ hostname
localhost

输入hostname命令即可查看当前电脑的主机. 此处已经进行了修改.

sudo scutil --set HostName yourName
# 操作实例
localhost:~ sean$ sudo scutil --set HostName Yanxm.HelloWorld
Password:
localhost:~ sean$ hostname
Yanxm.HelloWorld

Reference

[1]. Mac 修改HostName

©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页