CentOS how to change hostname?
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!
# system-config-network
and change hostname under DNS tab, logout then login again would do also.
Umarzuki
11 Sep 08 at 1:43 am
You don’t need to reboot, just logout and login.
tijn
4 Feb 09 at 4:24 pm
echo “newhostname” > /proc/sys/kernel/hostname and you dont need to reboot. Reboot is just for new kernel ;D
TheBigK
26 Mar 09 at 7:24 pm
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?
Pierluigi Vernetto
11 Jun 09 at 12:18 pm
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
Pierluigi Vernetto
11 Jun 09 at 12:26 pm
/etc/init.d/network restart will do after change the hostname.
nick
3 Dec 09 at 5:47 am
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
Bob
21 Dec 09 at 12:36 pm
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.
claudio
17 Feb 10 at 5:40 pm
don’t persist “after” restart… is the correct form…
Sorry again.
Good luck.
claudio
17 Feb 10 at 5:43 pm