Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got one problem with my linux webserver where I deployed from Virtual Machine template, usually i go to the console and then

issue the command hostname NEWSERVERNAME to make it happens and then followed by editing the /etc/hosts file and its done, but how come this time after the reboot it reverts back to the old template name ?

so i want it to be "wordpress" as the hostname but instead it reverts back to SSV as the name ?

any suggestion and comments is appreciated here.


share|improve this question
up vote 4 down vote accepted

Usually, I change the hostname using the following commands WITHOUT REBOOT:

$ sudo vim /etc/hostname
$ sudo vim /etc/hosts
$ sudo /etc/init.d/hostname restart

First, edit both files /etc/hostname to change the hostname, and edit /etc/hosts to add the new name. Then, run the hostname script as shown above.

All you need to do now is to terminate your current SSH session and reconnect to see the new host name.

share|improve this answer
thanks Khaled it works for now :-) – Server System Specialist Dec 6 '10 at 6:00

Check /etc/hosts, /etc/hostname, and /etc/mailname. You may want to run find /etc -type f | xargs grep $(hostname) to list all references.

share|improve this answer

In Debian and Ubuntu (which looks like the distribution you're using) to make your hostname stick through reboots, set it by editing the hostname file:

echo "wordpress" > /etc/hostname

Then make sure that your VPS hosting company will not override your hostname configuration via DHCPCD. In /etc/default/dhcpcdp ensure that the SET_HOSTNAME directive is commented out or it is set to 'no':


After rebooting your chosen hostname has to be active (you can also set it in that same session before rebooting with hostname -F /etc/hostname if you wish).

share|improve this answer

$sudo vim /ect/hotname change what you want to use :)

share|improve this answer

I believe the default is set in the /etc/HOSTNAME file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.