歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> CentOS 7更改Hostname

CentOS 7更改Hostname

日期:2017/2/28 13:56:03   编辑:Linux教程

在把VPS上的系統升級到CentOS 7之後,我嘗試修改/etc/sysconfig/network來修改hostname, 但是沒有用. 修改CentOS 7的Hostname的方法和以前版本不同,希望本文能幫你來修改Hostname在CentOS 7 / RHEL 7上。

使用hostnamectl來修改Hostname:

檢查目前的Hostname

[root@linuxidc ~]# hostnamectl status
Static hostname: linuxidc.guest
Icon name: computer-vm
Chassis: vm
Machine ID: 19a12d5f5d824794a19caf165a9b3bca
Boot ID: 21c75ffe0718431d800fd8159be13d99
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.20.1.el7.x86_64
Architecture: x86_64

設置新的Hostname

[root@linuxidc ~]# hostnamectl set-hostname mysql.jzbk.org

檢查當前Hostname

[root@linuxidc ~]# hostnamectl status
Static hostname: mysql.jzbk.org
Icon name: computer-vm
Chassis: vm
Machine ID: 19a12d5f5d824794a19caf165a9b3bca
Boot ID: 21c75ffe0718431d800fd8159be13d99
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-123.20.1.el7.x86_64
Architecture: x86_64

更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14

Copyright © Linux教程網 All Rights Reserved