How to change hostname in Linux
I’m trying to build an Oracle RAC system at work to understand how it works better. As part of this I had to build three Linux systems. I built one, then cloned it (it was a virtual machine in VMware).
But having done that, it of course kept the hostname of the first machine. So I had to work out how to change that.
It turns out that is quite easy.
- Edit file /etc/sysconfig/network using your favourite editor. In my case is nano.
- Look for HOSTNAME=xxxxxx
- Change the xxxx to the name you wish to set for your computer.
- Save the file and restart the xinetd service. (eg. type service xinetd restart in your shell)
Or simply reboot.