bash prompt doesn't change from $ to # for su
Hi All,
I'm trying to change the bash prompt and based on the man pages \$ should show a $ which changes to a # for a SU. However, this doesn't happen on my machine, it's $ for both user and SU. The line in .bashrc is: export PS1="\u@\h:\w\$" Thanks in advance. |
Hi,
I assume you mean the prompt for root. You will have to edit root's .bashrc for that. It is located in /root/.bashrc. Also: Make sure that you use su - to switch to root. This will give you a full login shell where root's .bashrc is definitely being sourced. |
Thanks. The root's .bashrc is symlinked to mine. So if I have \$ on my prompt shouldn't this work when changing to su?.
|
Well if it is symlinked to the same thing ... why would it change?? Remembering '\$' means take away the special meanings for the $ sign to give you a $ sign.
|
Try using single quotes instead of double quotes
export PS1='\u@\h:\w\$' Single quotes preserve the '\' in front of '$' echo "\u@\h:\w\$" \u@\h:\w$ echo '\u@\h:\w\$' \u@\h:\w\$ |
well, the man page says:
Quote:
which means, as I understand, that the $ should turn into a #. why does the symlink change anything? it's just a pointer to a .bashrc file to run. note the PS1 line is in double quotes (so it shouldn't be a literal $): export PS1="\u@\h:\w\$" |
Quote:
|
It's working with single quotes. Thanks.
|
All times are GMT -5. The time now is 12:04 PM. |