I'm trying to script some things and cannot figure out the correct syntax to append to root's .bashrc file. For this script, I'm just trying to get it to display the hostname in red when we ssh into it.

Normally, I append this below to /root/.bashrc and it works perfectly:

export PS1="\e[0;31m[\u@\h \W]\$ \e[m"

I've tried different variants of this below, but I can't figure out if the quotes are messing it up or what.

echo "export PS1="\e[0;31m[\u@\h \W]\$ \e[m"" >> ~/.bashrc

If I try the command above I'll get this error:

export PS1=e[0 bash: 31m[u@h: command not found...

Can you guys assist? TIA!


The answer is single quotes, like in

echo 'export PS1="\e[0;31m[\u@\h \W]\$ \e[m"' >> ~/.bashrc

  • You da man, thank you! – Riley Brown Apr 4 '19 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.