在 Ubuntu 系统中,可以通过以下几种方法查看主机名:
hostnamectl
命令hostnamectl
Static hostname
一行,该行显示的就是当前的主机名。/etc/hostname
文件cat /etc/hostname
hostname
命令hostname
/etc/hosts
文件cat /etc/hosts
127.0.0.1 localhost
的行,通常主机名会出现在这一行的末尾。通过以上几种方法,你可以轻松地查看 Ubuntu 系统的主机名。