setting the hostname, by Thomas Krichel

Introduction

In certain circomstances, a host needs to know its fully qualified domain name (FQDN). It tries to find out what name is associated with the IP address 127.0.0.1. This is not set in the DNS but on the local machine.

The /etc/hostname file

First you should check the hostname file
root@server:~# cat /etc/hostname
root@server:~# server
If you get something diffrent
root@server:~# nano /etc/hostname
and make sure you have server followed by a newline. Force a change in the hostname by
root@server:~# hostname -f /etc/hostname
This will not set the FQDN, for that you need /etc/hosts

The /etc/hosts file

Look at /etc/hosts.
root@server:~# nano /etc/hosts
This file should, at the top, contain two lines that look as follows.
127.0.0.1       localhost
127.0.0.1       server.openlib.org server
Use
root@server:~# nano /etc/hosts
to make sure you have the two lines there. You can test your setting by
root@server:~# hostname
root@server:~# server
root@server:~# hostname -f
root@server:~# server.openlib.org
This is the correct setup, if you don't see this something is wrong.