to setup the hostname in debian use these steps

for example i will be using ns1.domain.com as my hostname and domain with ip of 192.168.0.101

firs step to do is to edit /etc/hosts
nano /etc/hosts

it will look something like this:
127.0.0.1 localhost.localdomain localhost ns1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


now change it to look like this:
127.0.0.1 localhost.localdomain localhost ns1
192.168.0.101 ns1.domain.com ns1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


I basically added this second line: 192.168.0.101 ns1.domain.com ns1

after you have made the changes send these two commands:

Command:
echo ns1.domain.com > /etc/hostname


Command:
/bin/hostname -F /etc/hostname


if you just needed to setup your hostname stop here.



if you are continuing my tutorial, you can install your ssh now.
apt-get -f install

* i say yes to all the default prompts

once all the updates are completed:
apt-get install ssh




if you are following this Debian tutorial on install. go to the next step:
Next Step: Install BIND9