查看主机名的几种方式(如何查看电脑的主机名)

小编:芯水 更新时间:2022-08-24 00:27

1、Ubuntu 20.04查看主机名的几种方法如下。

root@hanyw1618-9999:~# hostname hanyw1618-9999 root@hanyw1618-9999:~# uname -a Linux hanyw1618-9999 5.15.0-33-generic #34-Ubuntu SMP Wed May 18 13:34:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux root@hanyw1618-9999:~# cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 hanyw hanyw666 127.0.0.1 hanyw-ubuntu ubuntu.demo01.hanyw.com bj.ubuntu01.hanyw.com test01.hanyw.com # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters root@hanyw1618-9999:~# uname -n hanyw1618-9999

2、hostname的man帮助手册如下。