本文主要是介绍MacOS 修改主机名 hostname ComputerName,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
MacOS 修改主机名
- 1,系统环境
- 2,修改hostname
- a. 查看hostname
- b. 修改hostname
- 3,修改ComputerName计算机名
- a. 查看计算机名
- b. 修改计算机名
- 4,MacOS 命令scutil
- a,查看命令
- b,修改命令
- 5,macOS Mojave 10.14.6
1,系统环境
y50M:~ y50$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14
BuildVersion: 18A389
2,修改hostname
a. 查看hostname
y50M:~ y50$ hostname
y50M.local
y50M:~ y50$ echo $HOSTNAME
y50M.local
y50M:~ y50$ scutil --get LocalHostName
y50M
y50M:~ y50$
b. 修改hostname
y50M:~ y50$ sudo scutil --set LocalHostName myMac
Password:
y50M:~ y50$ hostname
myMac.local
y50M:~ y50$
exit退出,重新打开terminal终端
myMac:~ y50$ hostname
myMac.local
myMac:~ y50$
3,修改ComputerName计算机名
a. 查看计算机名
myMac:~ y50$ scutil --get ComputerName
y50i
myMac:~ y50$
访达中显示
b. 修改计算机名
myMac:~ y50$ sudo scutil --set ComputerName myMacPro
Password:
myMac:~ y50$ scutil --get ComputerName
myMacPro
myMac:~ y50$
4,MacOS 命令scutil
a,查看命令
scutil --get HostName
scutil --get LocalHostName
scutil --get ComputerName
b,修改命令
$ sudo scutil --set LocalHostName 主机名
sudo scutil --set ComputerName 电脑名
5,macOS Mojave 10.14.6
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G95
LocalHostName
$ hostname
y50deimac
$ echo $HOSTNAME
y50deimac
$ scutil --get LocalHostName
y50mac
$ hostname
y50deimac
HostName
$ scutil --get HostName
HostName: not set
$ sudo scutil --set HostName y50macOS
$ scutil --get HostName
y50macOS
$ hostname
y50macOS
$ echo $HOSTNAME
y50deimac
ComputerName
$ scutil --get ComputerName
y50的iMac
$ sudo scutil --set ComputerName y50iMac
$ scutil --get ComputerName
y50iMac
╭─root@kali ~
╰─➤ ping y50imac
PING y50imac (192.168.1.6) 56(84) bytes of data.
64 bytes from y50imac (192.168.1.6): icmp_seq=1 ttl=64 time=55.2 ms
64 bytes from y50imac (192.168.1.6): icmp_seq=2 ttl=64 time=2.02 ms
- SSH 访问
╭─root@kali ~
╰─➤ ssh y50@y50imac
The authenticity of host 'y50imac (192.168.1.6)' can't be established.
ECDSA key fingerprint is SHA256:bO0vANc9nCaoK5Cq/eIPWy6W6LHHJDlrCvGF0AxLpdQ.
Are you sure you want to continue connecting (yes/no)? yes
参考:
- How to set hostname in Mac OS X with scutil
- Mac OS X 上修改主机名
- Mac OS X主机名称变化
- How to change your Mac’s name using the OS X Terminal
这篇关于MacOS 修改主机名 hostname ComputerName的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!