LINUX下查看系统构架,设置主机名和北京时间

2022/3/13 12:22:05      点击:

不管是LINUX下的CENTOS, DEBIAN, UBUNTU系统,你只要输入hostnamectl就能获取系统的构建,比如是KVM还是OPENVZ等,还可以获取系统的主机名,系统版本,内核信息等等,非常的简单方便,另外hostnamectl还可以设置主机名字,具体如下:

设置主机名
hostnamectl set-hostname host.example.com
设置为北京时间
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

=====输入hostnamectl获取基本信息=====

Static hostname: testserver
Icon name: computer-container
Chassis: container
Machine ID: d51bf2f4e93b4eb3a3b168f368ad1557
Boot ID: 2f49423bd0504066a3c8b5f9c5bec1c8
Virtualization: openvz
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0
Architecture: x86-64

Static hostname: newtestserver
Icon name: computer-vm
Chassis: vm
Machine ID: 178d6c4d71f9418e90b347741951d1d7
Boot ID: 3b9daccf9acd4ecf9188858f2f74817e
Virtualization: kvm
Operating System: Ubuntu 20.04.1 LTS
Kernel: Linux 5.4.0-104-generic
Architecture: x86-64