Modifying the hostname under CentOS requires three steps
1. Use the command: hostname to modify
shell>hostname www
2. Modify the /etc/sysconfig/network file:
NETWORKING=yes HOSTNAME=wang.localdomain
3. Modify the /etc/hosts file:
127.0.0.1 wang.localdomain new-hostname
From: http://www.cnblogs.com/anjou/archive/2007/08/04/842705.html
Reference: http://www.cnblogs.com/kerrycode/p/3595724.html