My bash prompt shows my hostname. If I change my hostname with the hostname command, in /etc/hosts, /etc/hostname and $HOSTNAME, the prompt still uses the old name. Is it possible to update this without logging out?

link|improve this question

33% accept rate
feedback

2 Answers

up vote 2 down vote accepted

If you have \h or \H in your prompt setting, its expansion is initialized when the shell starts, so you'll have to restart bash (exec bash). If that bothers you too much, change your prompt setting to print $HOSTNAME.

link|improve this answer
feedback

Try source ~/.bashrc

link|improve this answer
This does not work and never could unless there was an underlying mechanism used in .bashrc - it's not magic. – Sam Brightman Oct 16 '10 at 17:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.