dook dook - 3 months ago 24
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?

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 \$'