changing linux hostname without rebooting

changing linux hostname without rebooting

Post by Tony » Sat, 11 Oct 2003 03:37:13



How can I change the prompt of the linux hostname (REDHAT) without rebooting

I already changed /etc/hosts

 
 
 

changing linux hostname without rebooting

Post by Peter T. Breue » Sat, 11 Oct 2003 04:03:33



> How can I change the prompt of the linux hostname (REDHAT) without rebooting

The prompt is your PS1 variable. Change it any way you like.

Quote:> I already changed /etc/hosts

But why? That doesn't determine your hostname! CHANGE IT BACK!!!!! AT
ONCE!!!

Where do you (and other people) get the WEIRD idea from that changing
/etc/hosts will change your hostname? Does anything tell you so? No?
Will it mess up your networking? Yes. So WHY DO IT?

If you want to change your hostname, change it. Man hostname.

Peter

 
 
 

changing linux hostname without rebooting

Post by Mattias Honrendga » Sat, 11 Oct 2003 07:01:08



> How can I change the prompt of the linux hostname (REDHAT) without rebooting

> I already changed /etc/hosts

man hostname
man bash /PS1/
 
 
 

changing linux hostname without rebooting

Post by Jim Fische » Sat, 11 Oct 2003 07:44:06



> How can I change the prompt of the linux hostname (REDHAT) without rebooting

> I already changed /etc/hosts

FWIW, I've noticed that various system startup scripts use the boot-time
host name when configuring the system. And if you change the host name
after the system has booted, some existing configuration settings
continue to use the former (boot-time) host name, and not the new host
name. (A typical example is the firewall settings.) So this is why the
system should be rebooted (IMO) after the host name is changed.

FWIW, on Red Hat 8/9 boxes, the host name should be specified via the
GUI network configurator program within the X Windows environment:

    [root]# redhat-config-network
    # Click on the "DNS" tab

This ensures the appropriate RH8/9 system config files are updated as
needed. You should then reboot the system so that the startup scripts
are re-run using the new host name.

--
Jim

To reply by email, remove "link" and change "now.here" to "yahoo"
jfischer_link5809{at}now.here.com

 
 
 

changing linux hostname without rebooting

Post by Tony » Sat, 11 Oct 2003 10:06:25


why couldnt someone just tell me this:

echo "newhostname" > /proc/sys/kernel/hostname



> > How can I change the prompt of the linux hostname (REDHAT) without
rebooting

> > I already changed /etc/hosts

> FWIW, I've noticed that various system startup scripts use the boot-time
> host name when configuring the system. And if you change the host name
> after the system has booted, some existing configuration settings
> continue to use the former (boot-time) host name, and not the new host
> name. (A typical example is the firewall settings.) So this is why the
> system should be rebooted (IMO) after the host name is changed.

> FWIW, on Red Hat 8/9 boxes, the host name should be specified via the
> GUI network configurator program within the X Windows environment:

>     [root]# redhat-config-network
>     # Click on the "DNS" tab

> This ensures the appropriate RH8/9 system config files are updated as
> needed. You should then reboot the system so that the startup scripts
> are re-run using the new host name.

> --
> Jim

> To reply by email, remove "link" and change "now.here" to "yahoo"
> jfischer_link5809{at}now.here.com

 
 
 

changing linux hostname without rebooting

Post by Leon The Peo » Sat, 11 Oct 2003 12:31:27



Quote:> why couldnt someone just tell me this:

> echo "newhostname" > /proc/sys/kernel/hostname

Because thats a disaster to your system. If you just want to change your
shell prompt, change it like this

declare -x PS1

Then  the shell prompt appears as if you have changed the hostname.

If you want to change the hostname, you probably should reboot.

You could of course telinit 2,   change the hostname and telinit 5,
but that would disturb your services and applications, etc Its not a reboot,
but it almost is.

You could  also go through and restart every daemon    , to make sure they
got news of the hostname.

actually the hostname is stored in a few places

/etc/hosts
/etc/HOSTNAME or equivalent,
inside the memory of the shells (depending on the shell )
and inside the memory of every other process.

and in the kernel.

Its not something that is designed to be changed "without reboot".

and so the only simple answer to your question was to tell you to change
PS1. that is  effective for that one instance of that shell, and doesnt hurt
anything.

Nobody wanted to give you instructions that would cause confusion.

But if you want instructions on how to get yourself confused, please turn
over this message.

 
 
 

changing linux hostname without rebooting

Post by /dev/rob » Sat, 11 Oct 2003 12:58:24


Please do not top-post. Thank you.


> why couldnt someone just tell me this:

You got several correct answers. Why is that a problem? "man hostname"?

Quote:> echo "newhostname" > /proc/sys/kernel/hostname

Because it's wrong. That does not address the issue ...


>> needed. You should then reboot the system so that the startup scripts
>> are re-run using the new host name.

Your daemons were all started with the old hostname. You should change
whatever file RH uses to set the hostname (just do what Jim told you to
do!) and then "telinit 1" to go to single-user mode, and telinit back to
whatever runlevel you were in before. It's not rebooting, but it's about
the same: every process you're running except for the kernel itself and
init will be killed.
--

  or put "not-spam" or "/dev/rob0" in Subject header to reply
 
 
 

changing linux hostname without rebooting

Post by Peter T. Breue » Sat, 11 Oct 2003 17:05:54



> why couldnt someone just tell me this:

> echo "newhostname" > /proc/sys/kernel/hostname

Because it's (1) silly (man hostname !!!), (2) inadequate, (3) you
asked how to change the prompt, not the hostname, (4) you are an idiot
in the first place and you have no escape from that fact.




> > > How can I change the prompt of the linux hostname (REDHAT) without
> rebooting

Peter
 
 
 

changing linux hostname without rebooting

Post by Neil Horma » Sat, 11 Oct 2003 20:42:05



> How can I change the prompt of the linux hostname (REDHAT) without rebooting

> I already changed /etc/hosts

under Red Hat, if you actually want to change the hostname of the
system, you need to edit the file /etc/sysconfig/network
In that file you can specify the hostname with a line like:
HOSTNAME=<new hostname>
you can also specify your domain name, and a slew of other things.

then issue the command:
/etc/init.d/network restart

and your hostname will be changed.  IIRC the default Red Hat install
defines PS1 in your bash shell to be your hostname, so any subsequent
shells you open up will reflect the hostname change.

Neil

--
/***************************************************
  *Neil Horman
  *Software Engineer
  *Red Hat, Inc., www.redhat.com
  *gpg keyid: 1024D / 0x92A74FA1
  *http://www.keyserver.net
  ***************************************************/