Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using ubuntu-10.04 and bash. I want to go into root and have it change my prompt to underlined red characters to reflect that I am in root. At the bash prompt, if I type:

$ sudo bash

then I go into root, however my prompt doesn't change. In /root/.bashrc I have:

export PS1=$RED$UNDERLINE'\u@\h:\w\$'$DEFAULT' '

however this file isn't being read. In order for it to be read I have to enter at the prompt:

# . /root/.bashrc

which I don't want to have to do. How do I set it up so that when I go into root, /root/.bashrc runs automatically?

share|improve this question

2 Answers 2

  • First, is sudo root even a valid command? (sudo -s or sudo -i would be.)

  • I prefer editing my own .bashrc instead of root's. You can have, for example,

    if (( $UID == 0 )); then
    PS1="$PS1\u@\h:\w\$$DEFAULT "
  • You can use sudo -i to make root's rcfiles be read instead of yours.

share|improve this answer
Sorry, I meant to say sudo bash. You're right, sudo root is meaningless. Anyway, your suggestion of an if statement on the $UID works. –  Philip Hunt Apr 10 '11 at 11:58
@Philip: If an answer is helpful, consider marking it as accepted. –  grawity Apr 10 '11 at 12:07

Seems like sudo is configured to use the original users's environment variables and not the new ones.

Either you set the env_reset and env_keep options in /etc/sudoers or you explicitly reset the environment variables to the ones of the target user with -H: sudo -H -u root

share|improve this answer

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.