Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Thanks.

share|improve this question
add comment

5 Answers

up vote 3 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 :-) –  Albert Widjaja Dec 6 '10 at 6:00
add comment

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
add comment

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':

SET_HOSTNAME='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
add comment

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

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.