Change hostname permanently without a reboot

Asked by Tong Sun

Hi,

How to change hostname permanently without a reboot?

I've changed my /etc/hostname /etc/hosts, and want the system to reflect that. But:

% /etc/init.d/hostname start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service hostname start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start hostname
hostname stop/waiting

% start hostname
hostname stop/waiting

What does this "hostname stop/waiting" mean here?

Thanks

PS Ubuntu 10.10 Maverick

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu hostname Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
A. Denton (aquina) said :
#1

Hello!

The files "hostname" and "hosts" in /etc/-hive are different. The first one actually sets your hostname system wiede; whilst the latter defines aliases for systems to resolve them (e.g. to allow one to enter http://systemname/ in a browser instead of http://192.168.1.123).

That "/etc/init.d/hostname"-script seems bogus to me (at least in older Ubuntu versions). Forget about it!

"Rather than invoking init scripts through /etc/init.d, use the service(8) utility, e.g. service hostname start [...]" -- Yeah, that's right since the new versions of Ubuntu have changed. The old init-style system has been replaced by upstart.

"What does this "hostname stop/waiting" mean here?" -- I think it says what it does.

So solve your problem I recommend you to bring down all interfaces, configure what's necessary and bring them up again. The hostname setting should be in effect then. I'm not sure however whether something like "sudo ifdown ethX" and "ifup ethX" will be sufficient (old unix way). At least "/etc/init.d/networking" should not exist anymore since the changes took place. I'd try something like "service netwok(ing) restart" after you configured everything. Note that ALL connections will be broken then for a short time!

Can you help with this problem?

Provide an answer of your own, or ask Tong Sun for more information if necessary.

To post a message you must log in.