/etc/hostnameを編集して、Redhat7サーバーのホスト名を手動で変更する代わりに 専用コマンドhostnamectlを使用することをお勧めします この仕事をするために。デフォルトでは、他のオプションが指定されていない場合、hostnamectl コマンドは静的ホスト名を含む基本情報を表示します:
[root@rhel7 ~]# hostnamectl
Static hostname: rhel7
Icon name: computer
Chassis: n/a
Machine ID: 75387b56d72b44b380810499805ec28a
Boot ID: 6ad251d0e12a10e3af1894eae5fe5cb6
Virtualization: oracle
Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server
Kernel: Linux 3.10.0-123.el7.x86_64
Architecture: x86_64
set-hostnameを使用します オプション変更システムのホスト名。以下にrhel7-webを提供します ホスト名をに変更する引数 rhel7-web 。
[root@rhel7 ~]# hostname rhel7 [root@rhel7 ~]# hostnamectl set-hostname rhel-web [root@rhel7 ~]# hostname rhel-web
hostnamectl コマンドが/etc/hostnameの内容を自動的に変更しました :
[root@rhel7 ~]# cat /etc/hostname rhel-web