Au lieu de changer manuellement un nom d'hôte sur votre serveur Redhat 7 en modifiant /etc/hostname vous pouvez de préférence utiliser une commande dédiée hostnamectl pour faire ce travail. Par défaut, lorsqu'aucune autre option n'est fournie, le hostnamectl La commande affichera des informations de base, y compris le nom d'hôte statique :
[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
Utilisez set-hostname option change le nom d'hôte du système. Ci-dessous, nous fournirons rhel7-web argument pour changer le nom d'hôte en rhel7-web .
[root@rhel7 ~]# hostname rhel7 [root@rhel7 ~]# hostnamectl set-hostname rhel-web [root@rhel7 ~]# hostname rhel-web
Le hostnamectl la commande avait automatiquement changé le contenu de /etc/hostname :
[root@rhel7 ~]# cat /etc/hostname rhel-web