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 am installing a new Lucid Lynx server, and need to set the hostname.

I tried:

echo "squire" > /etc/hostname 
hostname -F /etc/hostname

That didn't work. anyone knows how to set the hostname?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

I believe the appropriate method from a normal user account is

sudo hostname testbox

Which successfully sets the hostname of my Lucid Lynx box to "testbox"

share|improve this answer
    
Thanks: this is the first time I got an answer answered so quickly. many thanks again :) –  stickman Jul 5 '10 at 17:30

As an asside, don't forget to add your new hostname in /etc/hosts, or else sudo (and a couple other things) will complain about unknown hosts.

Example: I changed my hostname from localhost to "tara" using sudo hostname tara, so I edited the line in /etc/hosts that was

127.0.0.1 localhost

and made it

127.0.0.1 localhost tara

(because I still wanted "localhost" to work, too)

share|improve this answer

Hostname -F does not work for me either. But try /etc/init.d/networking restart and ping your new hostname. Will be ok.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.