When should I use each of the two .bashrc files to set my aliases, prompt, etc?

link|improve this question

feedback

3 Answers

up vote 16 down vote accepted

/etc/bash.bashrc applies to all users

~/.bashrc only applies to the user in which home folder it is.

link|improve this answer
3  
And implied in dex's answer is... Use your local ~/.bashrc in all cases except where you want to enforce your will on everyone who uses that machine. – dacracot Oct 1 '09 at 14:21
Strictly speaking, you're not enforcing anything in /etc/bash.bashrc because users can always change it in their own ~/.bashrc – Kim Oct 1 '09 at 14:57
...except for when someone decides to make all variables readonly in /etc/bash.bashrc :\ – grawity Oct 1 '09 at 18:20
Under Ubuntu, this file, as commented at the beginning, has to be "sourced" from the /etc/profile file. I added an alias command at the end of the /etc/bash.bashrc, and appended the command "source /etc/bash.bashrc" at the end of the /etc/profile file. Works like a charm. – jfmessier Feb 6 '10 at 2:13
feedback

For your personal preferences and personal scripts or bash functions you should use .bashrc ( aliases, Added functions to bash ... )

The moment that you want to share something with all users ( or most of users ) or for things of general use ( Path for shared executables , path for documentation ...) put it in /etc/bash.bashrc

I said most of users because even let's say you specify a script greetings.sh which prints "Hello world!" for all users, but user Pepe want to use instead the script greetings.sh which prints "Hola el mundo!". He can modify his path in his .bashrc to point to his script instead of yours. In other word the user can always customize his session in .bashrc to what ever he wants.

link|improve this answer
feedback

Neither /etc/bash.bashrc nor /etc/bashrc are sourced by BASH, unless sourced from another file, such as .profile, .bash_profile, or .bashrc inside user $HOME

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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