dook dook - 1 year ago 102
Linux Question

Bash PS1 shows $ instead of # for root

When logging into root, the default prompt when echoed is

, which shows as
. I am trying to play around with the bash prompt so it displays the working directory.
export PS1="\w \$"

The prompt displays correctly, however, the symbol
does not transform into a
, even though my
is 0, which kind of defeats the purpose of omitting the user symbol
. Is there something extra I have to add, or does that symbol not work if I export it?

Answer Source
export PS1="\w \$"

This doesn't set $PS1 to \w \$, it sets it to \w $, as you can see if you type:

echo "$PS1"

Use single quotes:

export PS1='\w \$'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download