Wednesday, January 18, 2012

CentOS Change Hostname

In order to see the hostname type uname -n and dnsdomainname to see

Perform the steps below as root or sudo
  1. Change the HOSTNAME in /etc/sysconfig/network to desired new hostname
  2. Change the hostname in /etc/hosts. (Add to the same line as localhost)
  3. Source /etc/sysconfig/network
  4. Type hostname $HOSTNAME
  5. logout and log back in.

TIP: If you would like to strip off the domain name portion, which is stored elsewhere anyway.

  • sed -i.bak 's/\.[a-z].*//g' /etc/sysconfig/network

Reference
http://www.how2centos.com/centos-change-the-hostname/

No comments:

Post a Comment