返回首页
当前位置: 主页 > 操作系统 > centos教程 >

Centos 如何更改主机名

时间:2018-08-20 22:49来源:电脑教程学习网 www.etwiki.cn 编辑:admin

Centos 6.x
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.10.1

[root@localhost ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain server

 

 

 


Centos 7.x
[root@localhost log]# hostnamectl status
Static hostname: localhost.yvsy7
Icon name: computer-vm
Chassis: vm
Machine ID: 68a9a20de8ab4776a88eff33bd41b8ae
Boot ID: 405ba16753364bad82f4d057a51b6499
Virtualization: microsoft
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64
[root@localhost ~]# hostnamectl --static #静态
localhost.localdomain
[root@localhost ~]# hostnamectl --transient #瞬态
localhost.localdomain
[root@localhost ~]# hostnamectl --pretty #灵活
[root@localhost ~]# hostnamectl set-hostname server #同时修改三种状态主机名
[root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain server
# vim 替换快捷键
:%s/text/totext/g
[root@localhost ~]# hostnamectl --static set-hostname server #永久修改主机名


------分隔线----------------------------
标签(Tag):centOS Centos更改主机名
------分隔线----------------------------
推荐内容
猜你感兴趣