CentOS 7 のホスト名設定

以前も同じこと掲載してますが、ConoHa VPS の備忘録で残します。


一時的に変更

CentOS 6 と同じ。

変更

# hostname test-srv

確認

# hostname
test-srv

 

 

恒久的に変更

変更

# hostnamectl set-hostname cnh-srv

確認

# hostnamectl
 Static hostname: cnh-srv
 Icon name: computer-vm
 Chassis: vm
 Machine ID:  *****************************
 Boot ID: 16179d839d9949dcbdcc7acec42ab25e
 Virtualization: kvm
 Operating System: CentOS Linux 7 (Core)
 CPE OS Name: cpe:/o:centos:centos:7
 Kernel: Linux 3.10.0-693.11.6.el7.x86_64
 Architecture: x86-64

 

 

ホスト名が保存されているファイル

CentOS 6 の/etc/sysconfig/network とは異なります。

# cat /etc/hostname
cnh-srv

 

以上