Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

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
add comment

2 Answers

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/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
add comment

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
add comment

Your Answer

 
discard

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.