where exactly does bash get \h and \H hostname parameters used to set PS1 prompt?

Asked by costin

I want my bash prompt to display fqdn instead of hostname.

I am using ubuntu 12.04 lts amd64, installed from alternate cd, text install only, all default options, so I will paste only relevant bits.
when connecting to the machine using putty over ssh, my current prompt is like this:

myuser@imap:~$ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$

reading bash manual page, I understand that replacing \h with \H should change the prompt to display the fqdn

I did that, and the prompt does not change.

myuser@imap:~$ cat /etc/hostname
imap

myuser@imap:~$ cat /etc/hosts
127.0.0.1 localhost
192.168.17.71 imap.domainname.tld imap

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

So, to add this question to the one in the subject, how can I get bash to display fqdn in the least intrusive way?

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

You can set it in ~/.bashrc

It will set at boot and you can make it apply now with:

source ~/.bashrc

Revision history for this message
costin (costin) said :
#2

I KNOW where to set it. What I'm asking is something different:

1) why does bash not honour the \H parameter as documented
2) I could modify /etc/hostname to fqdn, I could set it in my .bashrc to "myuser@fqdn", and so on... but I want to do it the "official" documented way - what is it, and if there is no, is this a bug in bash?

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Rodney Beede (business2008+launchpad) said :
#4

That is a bug with how Ubuntu manages /etc/hostname.

Bug filed: https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1276796