Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 booted a guest vm on xen, and I want to assign guest-domU's hostname in config file. like this


It is a kernel command line to setting netboot networking environment.

It works fine on gentoo. Some codes in the file /etc/init.d/hostname are

  hostname $hostname

That will assign netboot hostname into real hostname.

But! on ubuntu 12, the script /etc/init/hostname.conf(upstart) only get the hostname value in /etc/hostname, or it will be none...

I've tried that edit the /etc/init/hostname.conf on ubuntu like

exec hostname=${hostname-${HOSTNAME-localhost}}
exec hostname "$hostname"

but it doesn't work...

Any help will be appreciated!! Thanks!

share|improve this question

I come here to answer my question... I should not erase all contents in /etc/init/hostname.conf(ubuntu), and write the same code of /etc/init.d/hostname(gentoo) into it. the original /etc/init/hostname.conf is

exec hostname -b -F /etc/hostname 

the workable hostname.conf is

export hostname=${hostname-${HOSTNAME-localhost}}
exec hostname $hostname

On Ubuntu, I should not direct assign variable like hostname=xxx, and I should prepend export to it.

It looks really stupid... haha.

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.