Networking Forums

Networking Forums > Computer Networking > Linux Networking > changing linux hostname without rebooting

Reply
Thread Tools Display Modes

changing linux hostname without rebooting

 
 
Tony
Guest
Posts: n/a

 
      10-09-2003, 06:37 PM
How can I change the prompt of the linux hostname (REDHAT) without rebooting

I already changed /etc/hosts



 
Reply With Quote
 
 
 
 
Peter T. Breuer
Guest
Posts: n/a

 
      10-09-2003, 07:03 PM
Tony <(E-Mail Removed)> wrote:
> 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.

> 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
 
Reply With Quote
 
Mattias Honrendgard
Guest
Posts: n/a

 
      10-09-2003, 10:01 PM
"Tony" <(E-Mail Removed)> wrote in message news:<bm49sr$ffg$(E-Mail Removed)>...
> How can I change the prompt of the linux hostname (REDHAT) without rebooting
>
> I already changed /etc/hosts


man hostname
man bash /PS1/
 
Reply With Quote
 
Jim Fischer
Guest
Posts: n/a

 
      10-09-2003, 10:44 PM
Tony wrote:
> 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

 
Reply With Quote
 
Tony
Guest
Posts: n/a

 
      10-10-2003, 01:06 AM
why couldnt someone just tell me this:

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


"Jim Fischer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Tony wrote:
> > 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
>



 
Reply With Quote
 
Leon The Peon
Guest
Posts: n/a

 
      10-10-2003, 03:31 AM

"Tony" <(E-Mail Removed)> wrote in message
news:bm50mj$gsb$(E-Mail Removed)...
> 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
PS1="(E-Mail Removed)"
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.








 
Reply With Quote
 
/dev/rob0
Guest
Posts: n/a

 
      10-10-2003, 03:58 AM
Please do not top-post. Thank you.

In article <bm50mj$gsb$(E-Mail Removed)>, Tony wrote:
> why couldnt someone just tell me this:


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

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


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

> "Jim Fischer" <(E-Mail Removed)> wrote in message
>> 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.
--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply
 
Reply With Quote
 
Peter T. Breuer
Guest
Posts: n/a

 
      10-10-2003, 08:05 AM
Tony <(E-Mail Removed)> wrote:
> 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.

> "Jim Fischer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Tony wrote:
> > > How can I change the prompt of the linux hostname (REDHAT) without

> rebooting


Peter
 
Reply With Quote
 
Neil Horman
Guest
Posts: n/a

 
      10-10-2003, 11:42 AM
Tony wrote:
> 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
************************************************** */

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MN700, Linux and Hostname MP Broadband Hardware 2 07-02-2004 01:38 AM
New to linux and confused about changing the hostname Patrick Shroads Linux Networking 3 02-17-2004 05:05 AM
Problem with Hostname changing to IP Address Nathan Given Linux Networking 6 09-17-2003 02:37 PM
Wrong posting: Changing Hostname made my Linux Box go crazy, Correction here N.K. Linux Networking 2 08-15-2003 01:20 PM
Linux hostname not accessible Jonathan Janssens Linux Networking 5 07-22-2003 08:46 AM



1 2 3 4 5 6 7 8 9 10 11