Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On one of my Ubuntu 11.10 servers, when I use sudo -i to become the root user, root's .bashrc is not being executed. On all other servers, whose relevant configurations are identical as far as I know, it is being executed properly.

Here's what I've checked:

  • .bashrc exists in /root, owned by root:root, permissions 644
  • /etc/profile and /etc/bash.bashrc are being executed
  • root's shell is set to "/bin/bash"
  • I can execute .bashrc with source .bashrc, after which everything is normal for that session.
  • I can also type bash to execute bash manually after I've sudoed to root, and .bashrc is then executed
  • ps confirms that the running shell for my root login is bash.

Anything else to check?

share|improve this question
1  
What is the content of /root/.profile? You know, .bashrc is not executed by default in login shells: on Ubuntu it is sourced from .profile. –  enzotib Jan 31 '12 at 10:46
    
That's it, thanks. .profile must have got deleted by mistake. If this was an answer, I would accept it. –  Mike Scott Jan 31 '12 at 11:19
add comment

2 Answers

up vote 6 down vote accepted

You should look at the presence and content of the file /root/.profile.

The init file ~/.bashrc is not sourced in login shells: on Ubuntu it is sourced from ~/.profile

Furthermore, the file /root/.profile is not copied from /etc/skel/ as for other users, it is instead copied from /usr/share/base-files/dot.profile during installation of package base-files.

share|improve this answer
add comment

There is one additional situation which you should keep in mind, which happened in my case.

If you would create .bash_profile file then this file is taking over the responsibility to load / execute .bashrc or .profile .

When you open your terminal and use "sudo -i" and you are suddenly missing some command aliases, file list coloring etc., then double check if this file is present in your home directory, then rename it and reopen your console again. This should fix it.

share|improve this answer
add comment

Your Answer

 
discard

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.