一、CentOS(6.5)
修改:vi /etc/sysconfig/network
[root@localhost ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=FTPServer
修改解析文件:vi /etc/hosts
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.80 FTPServer
重启网卡:service network restart
[root@localhost ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Determining if ip address 192.168.0.80 is already in use for device eth0...
[ OK ]
重启系统:reboot
查看主机名是否修改:hostname
[root@FTPServer ~]# hostname
FTPServer
二、CentOS7.*
查看主机信息:hostnamectl
[root@localhost ~]# hostnamectl
Static hostname: localhost.localdomain
Icon name: computer-vm
Chassis: vm
Machine ID: 7cdd2111a40b43c5b56eb40c4c926817
Boot ID: 3c6c5eb132bc4d54a7c118921dadeb79
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.el7.x86_64
Architecture: x86-64
修改主机名:hostnamectl set-hostname FTPServer
重启系统:reboot
查看主机名:hostname
[root@ftpserver ~]# hostname
ftpserver