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 have a virtual server running Debian Squeeze. I can change the hostname by running the hostname command or by editing /etc/hostname and then running /etc/init.d/, but after a reboot the hostname will be reset to the preconfigured hostname chosen by the server-hoster. I do not know which virtualization solution is used and I do not have access to an admin interface to change the hostname.

How can I change the hostname with a script each time the server boots?

share|improve this question
Have you tried a simple grep of /etc/init.d to see if anything else is setting the hostname? Maybe just give up on setting the hostname, why do you think you need to change it? Not much really depends on it, most applications can be configured to not use the system-defined hostname. – Zoredache Oct 5 '12 at 17:01

One simple, albeit slightly dirty method for this would be to put hostname yourhostname into /etc/rc.local.

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.