To change hostname on a Debian Server, just type in this command:
hostname NEW_NAME
Don’t forget to replace NEW_NAME by your new server name…
To make permanent, you will need to change it in this file:
vi /etc/hostname
then run this command to make it active right away!
/etc/init.d/hostname.sh start
You can also use this command to change the server name:
sysctl kernel.hostname=NEW_HOSTNAME
To change Domain Name:
All you do is edit /etc/hosts and change the domain name…
eg:
127.0.0.1 localhost
127.0.1.1 hostname.domainname.com hostname
Restart your server…
Have fun!