Linux修改主机名方法

[root@lyx ~]# vim /etc/hosts   vim代表修改,进入hosts文件进行添加192.168.10.128 hadoop128

[root@lyx ~]# hostname 查看主机名命令
lyx.wz.com
[root@lyx ~]# cd /       进入根目录
[root@lyx /]# vi /etc/sysconfig/network    讲道理,修改主机名在这个文件下修改,可是我没有成功,所以如若你没有成功,往下看。。。
[root@lyx /]# vi /etc/hosts
[root@lyx /]# hostname
lyx.wz.com
[root@lyx /]# hostnamectl status  查看主机的详细状态
Static hostname: lyx.wz.com
Icon name: computer-vm
Chassis: vm
Machine ID: 47b6edb5fd7a4c35a718c1eeaa742261
Boot ID: 6a11fda7a57f4e1094c0dda6639d2bd5
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1062.el7.x86_64
Architecture: x86-64
[root@lyx /]# cat /etc/hosts  
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.19.128 hadoop128
192.168.1.100 hadoop100
192.168.1.101 hadoop101
192.168.1.102 hadoop102
192.168.1.103 hadoop103
192.168.1.104 hadoop104
192.168.1.105 hadoop105
192.168.1.106 hadoop106
192.168.1.107 hadoop107
192.168.1.108 hadoop108
192.168.1.109 hadoop109

[root@lyx /]# cat /etc/hostname
lyx.wz.com
[root@lyx /]# hostname
lyx.wz.com
[root@lyx /]# hostnamectl set-hostname hadoop128  修改主机名为Hadoop128
[root@lyx /]# hostname  
hadoop128           修改成功
[root@lyx /]#

转载于:https://www.cnblogs.com/lyxcode/p/11609191.html

你可能感兴趣的:(Linux修改主机名方法)