hostnamectl #
修改主机名 #
bash
sudo hostnamectl set-hostname my-host
获取主机名 #
bash
hostname
获取主机状态 #
例1:
text
$ sudo hostnamectl status
Static hostname: gitlab
Icon name: computer-vm
Chassis: vm
Machine ID: 20190215172108590907433256076310
Boot ID: 788f5b14e3174e06afbaeb94bab0556c
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.71.1.el7.x86_64
Architecture: x86-64
例2:
bash
$ sudo hostnamectl status
Static hostname: DESKTOP-HK6M70F
Icon name: computer-container
Chassis: container
Machine ID: 61e09e7fe94f4782a91f62fe181de400
Boot ID: 04fecaaa073849df8bc6116b093e000f
Virtualization: wsl
Operating System: Ubuntu 22.04.3 LTS
Kernel: Linux 5.15.153.1-microsoft-standard-WSL2
Architecture: x86-64