1、方法一
使用hostnamectl命令 –会自动修改/etc/hostname,重新登录后生效
[root@bogon ~]# hostnamectl set-hostname vm63centos
2、方法二
修改配置文件 /etc/hostname 保存退出
[root@bogon ~]# vi /etc/hostname
vm239centos
不重启好像能生效
腾讯云Centos7服务器修改/etc/hosts
https://www.jianshu.com/p/2e27a4d7b9aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.redhat.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
# The following lines are desirable for IPv4 capable hosts
127.0.0.1 VM_100_63_centos VM_100_63_centos
127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost4.localdomain4 localhost4
# The following lines are desirable for IPv6 capable hosts
::1 VM_100_63_centos VM_100_63_centos
::1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
|
vi /etc/cloud/templates/hosts.redhat.tmpl
192.168.100.63 vm63centos
vi /etc/cloud/cloud.cfg 修改或删除manage_etc_hosts的值