使用hostname
或者hostnamectl
命令来检查当前主机名。
$hostname debian $hostnamectl Static hostname: debian Icon name: computer-vm Chassis: vm Machine ID: 37eaf1edf1864dee9cfa90373206a449 Boot ID: f4d3980df9da46f5b1a5dc997739f8b1 Virtualization: oracle Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.19.0-16-amd64 Architecture: x86-64
将我们的主机名更改为onitroad
$hostnamectl set-hostname onitroad
编辑/etc/hosts
文件,修改主机名
如果没有旧主机名,则将以下两行添加到文件中
127.0.0.1 onitroad ::1 onitroad
下次重启,系统将从此文件读取主机名。
日期:2020-07-07 20:56:10 来源:oir作者:oir