I changed my hostname by editing /etc/hostname and can see the new hostname using the hostname
and hostname -F
commands.
But the shell prompt is still showing the old hostname.
This is Ubuntu 11.0.4 by the way. The prompt is set in my .bashrc
which I have not edited. Logging out and even rebooting has no effect.
Relevant section of the standard Ubuntu .bashrc
:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
($debian_chroot is unset as I login...)
I guess the hostname is picked up by the special character \h.
Here's the PS1 setting as reported in the shell:
PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
And here is what PS1 shows:
username@oldhostname:~$
I repeated the process using the exact command in Warren's answer. It turns out that the hostname works until reboot but then it is lost, even though /etc/hostname
contains the new hostname.
echo $PS1
show?