Today I needed to change the hostname of my virtual guest machine running CentOS.
- Login with putty.exe
- Goto /etc/sysconfig/
- Type vi network
- Press i on the keyboard and change the HOSTNAME to your preferred servername
- Press ESC on the keybord
- Save the configuration by :wq!
- Reboot
That’s all!
Tags: CentOS
# system-config-network
and change hostname under DNS tab, logout then login again would do also.
You don’t need to reboot, just logout and login.
echo “newhostname” > /proc/sys/kernel/hostname and you dont need to reboot. Reboot is just for new kernel ;D
I have changed hostname, on a CentOS 5.3 on VMWare player, but after the change the startup becomes extremely slow, even opening Terminal takes 30s…. I have made sure the entry in the DNS tab in system-config-network is correct, and restarted…. if I restore the previous hostname value (bagvapp) the respose times become normal again…
anybody experiencing the same problem?
ah ok I forgot to add the new hostname in the 127.0.0.1 entry in the hosts file…
the procedure is described here:
http://javamonamour.blogspot.com/2009/06/centos-change-hostname-and-ips.html
/etc/init.d/network restart will do after change the hostname.
And you can also type as root in console: “setup” and then go to “Network Configuration” and edit the DNS config.
And you may want to check your /etc/hosts
Thanks guys, but the TheBigK’s solution don’t persist before restart.
The Umarzuki and Bob solutions are OK.
Muchas gracias, Thank to all.
Sorry for my bad english.
don’t persist “after” restart… is the correct form…
Sorry again.
Good luck.