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'm using ubuntu 10.04 on my server and I'm looking to set the hostname.

Looking around it seems I have to set this in the /etc/hostname file, but on my system I do not have one.

Typing hostname does return a value

Is there anywhere else this could be set?


share|improve this question
Do you actually have a full Ubuntu instance, or is this a chroot, or something? – Zoredache Jan 27 '12 at 19:52
AFAIK, every linux system has /etc/hostname. Most likely your system is either chrooted, or just screwed up ;) – Andrejs Cainikovs Jan 27 '12 at 20:36

On Ubuntu server that is the correct location. You just need to add the hostname string only to the file, example:

echo my-ubuntu-server-name > /etc/hostname and reboot.

share|improve this answer
Actually just run /etc/init.d/ start and it will set it for you as well. – Squidly Jan 27 '12 at 19:30
I get /etc/init.d/ start -bash: /etc/init.d/ No such file or directory – terrid25 Jan 27 '12 at 19:31
No /etc/init.d/ on my ubuntu server either, maybe you meant /etc/init.d/hostname? – Tim Jan 27 '12 at 19:49

This is strange you don't have /etc/hostname

Try to find where your hostname comes from:

grep -r 'yourHostName' /etc  

If you have too many lines (because your hostname is a very common word into your /etc), then use 'hostname' command to set a new one:

hostname xxxMyHostNamexxx  

then restart your search with grep (maybe the missing file will be created by the previous command).

Also search into /usr/

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.