主机名值的来源

问题描述

在这个 mac mini 上有一个提示,看起来像下面的输出。我似乎可以找到 priscilla-cs-iphone 值的来源。

mando@priscilla-cs-iphone ~> cat .config/fish/fish_variables | grep hostname
mando@priscilla-cs-iphone ~ [0|1]> cat .config/fish/fish_variables | grep home
mando@priscilla-cs-iphone ~ [0|1]> cat .config/fish/fish_variables | grep priscilla
mando@priscilla-cs-iphone ~ [0|1]> cat .config/fish/fish_variables | grep "priscilla"
mando@priscilla-cs-iphone ~ [0|1]> cat ~/.config/fish/fishd.(ifconfig en0 | awk '/ether/{print $2}' | tr -d ':')
cat: /Users/mando/.config/fish/fishd.1498773cea14: No such file or directory

系统配置...

mando@priscilla-cs-iphone ~ [1]> defaults read /Library/Preferences/SystemConfiguration/com.apple.smb.server
{
    DOSCodePage = 437;
    LocalKerberosRealm = "LKDC:SHA1.30D481C6036FC8F8B589EFF8E37B513D08753210";
    NetBIOSName = mandalarian;
    ServerDescription = mandalarian;
}
mando@priscilla-cs-iphone ~>

我的 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

我使用的是 mac mini:

> sw_vers
ProductName:    macOS
ProductVersion: 11.2.3
BuildVersion:   20D91

我知道我可以重置它,但我想知道值的来源以及如何设置它。这是全新的 BigSur 安装,在过去 24 小时内我从未连接到我知道的 iPhone。

解决方法

Fish 调用操作系统的 gethostname(3) 函数。

获取值的位置取决于系统。 macOS 从哪里得到它,我完全不知道。