My .bash_profile has different styles of prompt for regular user and root but in order it to work the .bash_profile should be reloaded every time I switch users. How can I achieve this?

Can I make the command . ~/.bash_profile to be executed every time I execute su command in order to change the prompt look for root?


Define the custom prompt of root in his .bash_profile, not in your regular user's profile. Usually this is the default setup anyway, without manually having to edit it.

Note that when you use su without arguments, it doesn't read root's rc files, that's why the prompt doesn't change. To make su read root's rc files, use su - (with a dash as parameter). That way, normally, you should see root's custom prompt instead of your user's.

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.