0

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?

Thanks

terrid25
  • 251
  • 2
  • 5
  • 12

2 Answers2

3

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.

Tim
  • 3,017
  • 17
  • 15
  • Actually just run /etc/init.d/hostname.sh start and it will set it for you as well. – Squidly Jan 27 '12 at 19:30
  • I get `/etc/init.d/hostname.sh start -bash: /etc/init.d/hostname.sh: No such file or directory` – terrid25 Jan 27 '12 at 19:31
  • 1
    No `/etc/init.d/hostname.sh` on my ubuntu server either, maybe you meant `/etc/init.d/hostname`? – Tim Jan 27 '12 at 19:49
0

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/

Gregory MOUSSAT
  • 1,673
  • 2
  • 25
  • 50