Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a VPS with Centos 6.5

I've setup ~/.bash_profile as in the following screenshot:

enter image description here

It used to give me an output like this: enter image description here

Now that I've installed WHM/Cpanel I no longer see coloured prompt.

echo $PATH shows:


How can I fix this? Can anyone help me?

Everything else works according to the configuration. Grep and ls shows coloured outputs. I need this to work as I find it convenient to quickly spot previous commands and outputs.

share|improve this question
$PATH is not a command but an environment variable where are stored directories containing binaries to run directly in the command line (without typing the full path). Type echo $PATH to display its value. Your $PATH variable seems to be OK. and Have nothing to do with your issue. – Slyx Apr 9 '14 at 10:25
Yes Slyx, you are right. I should have pasted the output of "echo $PATH". Wonder, what is wrong then. – Jay Apr 9 '14 at 10:31
Type echo $PS1 to see if its value was altered. May be the $PS1 is modified elsewhere before you get the prompt. If so, type . .bash_profile to reload it. – Slyx Apr 9 '14 at 10:41
If you are not running a login shell, then your ~/.bash_profile won't get sourced, only .bashrc. How are you starting bash? If you are simply typing bash from the command line and PATH is also set inside your .bashrc, then this would explain what you see. – Graeme Apr 9 '14 at 10:56
Spot on! "echo $PS1" shows "\u@\h [\w]#" in the output which is different. I noticed cpanel/whm had made many changes to /etc/bashrc which might be causing system wide changes. In fact they even have comments about issues with their configuration. I've edited the bashrc file and everything is working now. Thanks for your help. – Jay Apr 9 '14 at 11:08
up vote 0 down vote accepted

Bash's management of initialization files is bizarre. In a login shell, bash reads /etc/profile and ~/.bash_profile only. In an interactive non-login shell, bash reads /etc/bash.bashrc and ~/.bashrc only. (I'm simplifying somewhat, read the manual if you really want the full details.)

To curb the madness, use the following content in ~/.bash_profile:

# Read the shell-agnostic login hook
if [ -e ~/.profile ]; then . ~/.profile; fi
if [[ $- = *i* ]]; then
  # This is an interactive shell, so read bash's interactive login hooks
  # (which bash omits in login shells)
  if [[ -e /etc/bash.bashrc ]]; then . /etc/bash.bashrc; fi
  if [[ -e /etc/bashrc ]]; then . /etc/bashrc; fi
  if [[ -e ~/.bashrc ]]; then . ~/.bashrc; fi

Put login-time stuff like environment variable definitions (e.g. PATH, EDITOR) in ~/.profile. Put interactive stuff like prompt settings and aliases in ~/.bashrc.

For more information, see Is there a Bash file that will be always sourced in interactive mode no matter if it is login or non-login?, Difference between Login Shell and Non-Login Shell? and Difference between .bashrc and .bash_profile

share|improve this answer
Thanks for the explanation Gilles. But I found a much simpler solution. – Jay Apr 17 '14 at 11:33
Thanks mate, I read the manual and found there was this line at the bottom that needed deleting, if [ -f ~/.bashrc ]; then . ~/.bashrc; fi At this moment I've if [[ -e ~/.bashrc ]]; then . ~/.bashrc; fi at the top in ~/.bash_profile. ~/.bashrc has default values. I've deleted the word "export" and have default /etc/bashrc file (deleted any changes I made in that file) and I still have colours. :) Completely missed that last line in `.bash_profile' because of its formatting or may be it wasn't a single line. Cheers. – Jay Apr 17 '14 at 12:28

Just answering my own question, in case someone else run into the same issue.

You can either assign the PS1 variable in /etc/bashrc for all the users or comment out and use /.bash_profile for an individual account. In my case /.bash_profile was already setup and all I've to do was to disable PS1 in /etc/bashrc.

Refer to the following screenshot. After the modification, reboot or ssh again. Notice the comments left by cPanel developers.

enter image description here

Many thanks to Slyx and everyone for their valuable responses.

share|improve this answer
That “simpler solution” is going to land you into similar problems later. Don't set PS1 in .profile or similar. Don't use export in .bashrc or similar. The fact that the comment author hasn't figured out what's going on should be a sign not to stick to what they're doing. – Gilles Apr 17 '14 at 11:40
Interesting, before trying out my fix, I did edit both files /.bashrc and /.bash_profile as per your explanation but the result was the same - no colours. /etc/bashrc always get the preference. I do not have any ~/.profile file. Shall I create one and what should I include in it? Thanks. – Jay Apr 17 '14 at 11:53
If you don't have anything to put in .profile, leave it empty. It's for things like environment variables (but you can put them in ~/.pam_environment as well). Use the .bash_profile in my answer, that way .bashrc is always read. You can put . /etc/bashrc there as well (I didn't include it because that file is distribution-specific). – Gilles Apr 17 '14 at 12:02
Fixing /etc/bashrc fixed my issue, thanks! – fusion27 Jun 24 '14 at 13:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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