如何修改hostname

修改hostname hostnamectl set-hostname hadoop001然后重启 reboot

July 11, 2019 · 1 min · jiezi

搞懂 macOS 上的主机名/hostname/ComputerName

主机名/hostname/ComputerName 的含义主机名、hostname 是一个东西,中英文而已,指的是你本地网络上的电脑可以通过主机名访问你的电脑。这个与 Linux 系统是一致的。ComputerName,这个是 macOS 才有的东西。跟 Windows 上一样,表示的是电脑名称,给人看的。可以从下图中看出来(系统偏好设置 > 共享):15517939724708.jpg对于 macOS 来说,它会按以下的顺序来确定主机名,直到获取到为止:从以下文件中读取:/etc/hostconfig从以下系统配置项读取:/Library/Preferences/SystemConfiguration/preferences.plist 中的 System ▸ System ▸ HostName由本机 IP 地址的反向 DNS 查询获取从以下系统配置项读取:/Library/Preferences/SystemConfiguration/preferences.plist 中的 System ▸ Network ▸ HostNames ▸ LocalHostName如果以上方法都没获取到,就为默认的 localhost主机名/hostname 修改查看hostname或者scutil –get LocalHostName修改sudo scutil –set LocalHostName XXX示例$ hostnameshocker.local$ scutil –get LocalHostNameshocker$ sudo scutil –set LocalHostName helloPassword:$ hostnamehello.local$ scutil –get LocalHostNamehelloComputerName 修改查看scutil –get ComputerName修改sudo scutil –set ComputerName XXX示例$ scutil –get ComputerNameshocker$ sudo scutil –set ComputerName MyMacBookPassword:$ scutil –get ComputerNameMyMacBookscutil 命令scutil 是个可动态访问 macOS 系统信息的交互式工具。$ scutil –helpusage: scutil interactive access to the dynamic store. or: scutil –prefs [preference-file] interactive access to the [raw] stored preferences. or: scutil [-W] -r nodename or: scutil [-W] -r address or: scutil [-W] -r local-address remote-address check reachability of node, address, or address pair (-W to “watch”). or: scutil -w dynamic-store-key [ -t timeout ] -w wait for presense of dynamic store key -t time to wait for key or: scutil –get pref or: scutil –set pref [newval] or: scutil –get filename path key pref display (or set) the specified preference. Valid preferences include: ComputerName, LocalHostName, HostName newval New preference value to be set. If not specified, the new value will be read from standard input. or: scutil –dns show DNS configuration. or: scutil –proxy show “proxy” configuration. or: scutil –nwi show network information or: scutil –nc show VPN network configuration information. Use –nc help for full command list or: scutil –allow-new-interfaces [off|on] manage new interface creation with screen locked. or: scutil –error err# display a descriptive message for the given error code查看 DNS 配置$ scutil –dnsDNS configurationresolver #1 nameserver[0] : 61.139.2.69 nameserver[1] : 218.6.200.139 if_index : 5 (en0) flags : Request A records reach : 0x00000002 (Reachable)resolver #2 domain : 8163912288.members.btmm.icloud.com options : pdns timeout : 5 flags : Request A records reach : 0x00000000 (Not Reachable) order : 150000// more …查看代理配置$ scutil –proxy<dictionary> { HTTPEnable : 0 HTTPSEnable : 0 ProxyAutoConfigEnable : 0 SOCKSEnable : 0}查看网络配置$ scutil –nwiNetwork informationIPv4 network interface information en0 : flags : 0x5 (IPv4,DNS) address : 192.168.0.105 reach : 0x00000002 (Reachable) REACH : flags 0x00000002 (Reachable)IPv6 network interface information No IPv6 states found REACH : flags 0x00000000 (Not Reachable)Network interfaces: en0修改主机名、电脑名称等$ scutil –set ComputerName xxx$ scutil –set HostName xxx$ scutil –set LocalHostName xxx参考Where does the prompt name come from in the macOS Terminal?How to set hostname in Mac OS X with scutil感谢您的阅读,觉得内容不错,点个赞吧 ????原文地址: https://shockerli.net/post/ma… ...

March 5, 2019 · 2 min · jiezi