LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   System wide .bashrc file - bad idea? (https://www.linuxquestions.org/questions/linux-newbie-8/system-wide-bashrc-file-bad-idea-4175422666/)

ForumUser2 08-17-2012 03:58 PM

System wide .bashrc file - bad idea?
 
I am a bash user who would like to create multiple logins on a single Linux workstation where each login would have a distinct user environment for development.

I currently use the .bashrc file in each users home directory for most of my bash environment set-up. It occurred to me that I could create a 'system wide' .bashrc (for settings common to all users) in /usr/etc and then source it from the .bashrc in each home directory.

The fact that I've never seen this done before makes me wonder if there are some obvious downsides that I don't see.

Any advice?

suicidaleggroll 08-17-2012 04:11 PM

/etc/bashrc and /etc/profile are standard on most linux distros, you probably already have them. Often they will automatically source any .sh file in /etc/profile.d/ as well, which is where it's recommended you place global environment setup functions like the one you're planning.

devnull10 08-17-2012 05:36 PM

If you just sourced it in each users .bashrc, the user could just change that file if they wanted to exclude it (or delete and recreate it). So don't rely on it.

ForumUser2 08-17-2012 10:00 PM

@suicidaleggroll: thanks for the pointer, got me going in the right direction.

On my system (Ubuntu 11.10) the /etc/profile.d only has a script dealing with 'bash_completion'. There is no /etc/bashrc, but there is a /etc/bash.bashrc file. Like ~.bashrc, the bash.bashrc is getting sourced implicitly during creation of sub-shells, but not login shells.

This would certainly work for my goal of having a single location for system wide bash environment settings. I can put the global settings in /etc/bash.bashrc and then source both ~.bashrc and /etc/bash.bashrc from the ~.profile files.


All times are GMT -5. The time now is 04:30 PM.