Take the 2-minute tour ×

I'm using centos in my VPS server and guest system. There're two logins for a guest system. One is root and one is regular. After I mounted the guest system and chroot to the mounting directory, I switched to the regular account in the mounted guest system. Then the brackets missed as shown below:

[root@server image]# chroot /mnt/guest34
[root@server /]# su - regular
-bash-4.1$ sd
-bash: sd: command not found
share|improve this question
add comment

migrated from serverfault.com Jun 6 '13 at 19:40


3 Answers

up vote 10 down vote accepted

You should read about .bash_profile and .bashrc. The bracketed information is just a preference in those files which typically live in your home directory and/or /etc/profile (look for the line that starts PS1=). I'm assuming that when you're chrooted, that user does not have access to its home folder to load these files, so your prompt is, essentially, un-customized.

Most modern distros will display something like [user@server directory]# but this behavior is controlled by these two files. What you're seeing is bash with no customizations, since they cannot be loaded from the user's home.

share|improve this answer
add comment

What's your question?

The appearance of the prompt is defined by the $PS1 variable. Your regular account just doesn't have the brackets in the variable's value.

If you want your regular prompt to look like your root prompt, first log in as root and echo $PS1 and copy or write down the value. Then switch to regular and set that as the value of $PS1. Save it in ~/.bashrc if you want it to stick.

All of this is explained in greater detail in man bash.

share|improve this answer
add comment

or, you could just clone this:

git clone git://github.com/christopher-barry/bash-color-tools.git

run ./install from the root of the tree, and have custom theme-able color prompts :)

share|improve this answer
add comment

Your Answer


