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

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

2 Answers 2

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.

3
  • Actually just run /etc/init.d/hostname.sh start and it will set it for you as well.
    – Squidly
    Jan 27, 2012 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, 2012 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, 2012 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/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .