Renomeie o nome do host RedHat7 sem reiniciar

Renomeie o nome do host RedHat7 sem reiniciar

Como renomeio o nome do host RedHat7 sem reinicializar? Também estou tentando automatizar essa tarefa.

Responder1

[root@stephan ~]# echo stephan2 > /etc/hostname # this is the file that your system reads on boot, to determine the hostname
[root@stephan ~]# sed -i s/stephan/stephan2/g /etc/hosts # many networking headaches will ensue if this isn't updated
[root@stephan ~]# hostname -F /etc/hostname # reread the hostname file to update the systems hostname.

Seu prompt continuará exibindo o nome do host antigo até que você efetue logout e login novamente ou execute uma nova sessão de shell.

[root@stephan ~]# logout
[stephan@stephan ~]$ sudo su -
Last login: Wed Sep 28 18:06:35 EDT 2016 on pts/0
[root@stephan2 ~]#

Responder2

Use o seguinte comando para alterar o nome do host no RHEL7:

hostnamectl set-hostname name

Para visualizar os nomes de host atuais:

hostnamectl status

Consulte oRede Red Hat Enterprise Linuxguia para obter mais detalhes.

informação relacionada