I am attempting to use a simple shell script on a base Ubuntu 12.04 server install to set prompt colors for users system wide.

I would like to have Puppet place the file color.sh in /etc/profile.d/ -- with permission 744

but the file isn't being sourced by users at all. ~/.bashrc appears to override this.

    if [[ ${EUID} == 0 ]] ; then
        PS1="\\[\\033[01;31m\\]\\h\\[\\033[01;34m\\] \\W \\$\\[\\033[00m\\] "
        PS1="\\[\\033[01;32m\\]\\u@\\h\\[\\033[01;34m\\] \\w \\$\\[\\033[00m\\] "

I would prefer not to manipulate ~/.bashrc files with Puppet, but instead have this work globally with profile.d script.


The default Ubuntu ~/.bashrc will overwrite any earlier values of PS1 which is what you're seeing. You could make PS1 read only

declare -r PS1=...

but this will cause the default ~/.bashrc to emit

-bash: PS1: readonly variable

which may not be desirable. You can edit /etc/skel/.bashrc to remove the lines that set PS1 so that new users will not get init scripts that by default try and overwrite your global PS1 definition. That won't stop them from adding their own PS1 definitions but the error message above would clue them in.

  • Thank you! I ended up using /etc/skel/.bashrc and put the prompt colors for user and root in there. Works great now. – sepulworld Mar 20 '13 at 4:21

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.