操作系统:CentOS7
实战经验:修改CentOS7的主机名与CentOS6有所区别,使用CentOS6的方式并不能成功的修改主机名
1.ifconfig命令未找到
[sky9890@146 ~]$ ifconfig
-bash: ifconfig: 未找到命令
[root@146 sky9890]# yum install net-tools.x86_64 #安装之后即解决未找到命令问题
[root@146 sky9890]# exit
[sky9890@146 ~]$
2.如何修改主机名?
[root@146 ~]# hostnamectl
Static hostname: localhost.localdomain
Transient hostname: 146.210.195.113.adsl-pool.jx.chinaunicom.com
Icon name: computer-server
Chassis: server
Machine ID: 0c0cbc9b5a6e41aea67b15a33c3c03e8
Boot ID: 926436efd0944b6dbbecc4b33d8c4369
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.11.6.el7.x86_64
Architecture: x86-64
[root@146 ~]# hostnamectl --static set-hostname CentOS7 #静态修改主机名之后,重新连接或重新启动
[sky9890@CentOS7 ~]$
[sky9890@CentOS7 ~]$ hostnamectl
Static hostname: CentOS7
Icon name: computer-server
Chassis: server
Machine ID: 0c0cbc9b5a6e41aea67b15a33c3c03e8
Boot ID: 0c8c8aa3bdec4ccc98c1352e42426e4a
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.11.6.el7.x86_64
Architecture: x86-64