To do this you should use the hostname command:
hostname
for instance:
hostname ns1.server.com
(Where "ns1.server.com" is the name of your machine)
Then you need to edit some configuration files.
Debian/ Ubuntu
/etc/hostname
You need to put hostname there, it can be done in the following way:
echo "ns1.server.com" > /etc/hostname
Where "ns1.server.com" is the name of your machine
or
vi /etc/hostname
now it should look like:
cat /etc/hostname
ns1.server.com
CentOS / Redhat
You have to edit /etc/sysconfig/network
cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=dXXXX.seedhost.eu
GATEWAY=213.186.XX.254
Just change the HOSTNAME variable
For instance :
vi /etc/sysconfig/network
after edit file it should look like that:
NETWORKING=yes
HOSTNAME=ns1.server.com
GATEWAY=213.186.XX.254
Now you have to edit /etc/hosts
vi /etc/hosts
Just change the variable dXXXX.seedhost.eu
FreeBSD
As root, type "hostname ", and the hostname will be changed
instantly. To keep this change across reboots, edit the file
'/etc/rc.conf', and add such a line:
Set the hostname variable to your host name:
hostname="ns1.server.com"