Ubuntu – Anomaly with bash PS1 definition

bashcommand lineprompt

My root and admin user both have the same .bashrc file.

The prompt section of the .bashrc is the following:

         if [ "$color_prompt" = yes ]; then
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 
                PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 
         unset color_prompt force_color_prompt

         # If this is an xterm set the title to user@host:dir 
         case "$TERM" in xterm*|rxvt*)
                PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

But the problem is that the admin user and root user have different prompts.

admin's prompt is:


and root's prompt is


So it seems root is using the "xterm" version and admin is not.

Why does the .bashrc file have this difference in prompts? How do I get the admin user to also use the xterm version?

How would I test that condition?

If I run echo $TERM while running as the admin user I get xterm so as far as I can tell, it should be using the xterm version for the admin user.

Best Answer

It works as expected.

By convention, the prompt ends with $ for users and by # for root. This is the \$ in PS1.

The other difference is the ~ vs /home. This is also normal. It is the \w part of the prompt, the current working path. If it begins with the content of $HOME, it is replaced by ~.