We can change the hostname of a machine by several ways. I am mentioning two ways to change the hostname.
Method 1 :- Editting /etc/sysconfig/network file
- Open the terminal or Login with putty.exe as root user (if you are working remotely)
- Goto /etc/sysconfig/
- Type nano network
- Change the HOSTNAME to your preferred machine name
- Press Cntrl+X
- Save the configuration by pressing Y
- Log off or reboot
Method 2:- Editting /proc/sys/kernel/hostname file
- Open the terminal or Login with putty.exe as root user (if you are working remotely)
- Goto /proc/sys/kernel/
- Type nano hostname
- Change the HOSTNAME to your preferred machine name
- Press Cntrl+X
- Save the configuration by pressing Y
- Close the terminal and login again
In this method, no reboot is required to get the change in effect
Note: Add the ipaddress and new hostname to /etc/hosts file also