HowTo Change Hostname in Linux

To check for current hostname:

1
hostname
Change hostname
1
hostname new_hostname
Make change permanent on reboot:
  • Debian/Ubuntu: edit or make changes on this file /etc/hostname
  • RHEL/CentOS: edit or make changes on this file /etc/sysconfig/network
Important:
Make sure to check or update new hostname in /etc/hosts as some running application could be using hostname values in there. Test running applications as well or try to reload/restart if possible (ex: apache).

No comments:

Post a Comment