[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á a exibir o nome do host antigo até você efetuar logout dele e voltar, ou executar uma nova sessão do shell.
[root@stephan ~]# logout
[stephan@stephan ~]$ sudo su -
Last login: Wed Sep 28 18:06:35 EDT 2016 on pts/0
[root@stephan2 ~]#