在『系統偏好設定』中已經設定了正確的電腦名稱,可是每次在公司內部連上網路之後打開終端機,命令提示字元上顯示的卻是上一次使用這個 IP 的電腦名稱,如果這一點讓你困擾的話,可以試試下面這個指令修改 HostName:

sudo scutil --set HostName [新名稱]

scutil 這個命令支持下列的參數:

--get pref
    Retrieves the specified preference.  The current value will be
    reported on standard output.

    Supported preferences include:
          ComputerName   The user-friendly name for the system.
          LocalHostName  The local (Bonjour) host name.
          HostName       The name associated with hostname(1) and gethostname(3).

--set pref [newval]
    Updates the specified preference with the new value.  If the new value is not
    specified on the command line then it will be read from standard input.

    Supported preferences include: ComputerName LocalHostName HostName

    The --set option requires super-user access.

但以我的情況是只要修改 “HostName” 就可以了,其他兩個使用 get 查看都跟我設定的一樣,修改後記得重新開啟 Terminal 或是 iTerm 使其生效。

最後修改日期: 2022-06-04

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。