change hostname debian

Change the hostname of a debian host

To get an idea what configuration files may be you using the old-current hostname it helps to grep /etc/ for the old-current hostname, eg:
# grep -ril `hostname -f` /etc/

Update /etc/hostname
# echo "" > /etc/hostname

Update /etc/hosts ,eg:
#IP Address  FQDN             Alias1  Alias2  AliasN  ahost

Update /etc/mailname
# echo "" > /etc/mailname

Update SSH Host Keys
Replace root@old_hostname with root@new_hostname --the last words-- in /etc/ssh/ and /etc/ssh/
Restart the SSH deaemon.

For Postfix update myhostname= in /etc/ and restart the daemon

For ssmtp update hostname= in /etc/ssmtp/ssmtp.conf

Many daemons have some hostname definition in their configuration files that may need to be changed.

If possible restart the system.

Debian Wiki Change Hostname