在 Ubuntu 中,您可以使用以下方法之一來查看 hostname:
方法 1:使用命令行終端
hostnamectl
輸出中會顯示 “Static hostname” 和 “Transient hostname” 兩個條目。其中 “Static hostname” 是您的主機名。方法 2:使用 uname 命令
uname -n
輸出將顯示當前的主機名。方法 3:查看 /etc/hostname 文件
cat /etc/hostname
輸出將顯示當前的主機名。方法 4:查看 /etc/hosts 文件
cat /etc/hosts
在文件中找到 “localhost” 一行,其后的主機名即為當前的主機名。