System Wide Bash Login Script

Matthew Pherigo hybrid120 at gmail.com
Tue Dec 17 23:56:08 UTC 2013


Hi Drew!

Believe it or not, systemwide bashrc sourcing isn't actually built-in to bash by default (though in my opinion, it should be). This behavior of global config sourcing actually comes from default /etc/profile files that come with Linux distros. Since FreeBSD uses csh/tcsh by default, of course, it comes with no such thing. However, it's fairly easy to add. The following snippet of code goes into your /etc/profile:

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    if [ -f /usr/local/etc/bash.bashrc ]; then
      . /usr/local/etc/bash.bashrc
    fi
  fi
fi

If the shell is interactive, is a bash shell, and the file /usr/local/etc/bash.bashrc exists, it sources it.

This is the snippet of code I use; I think it was originally from Debian. 
--Matt

> On Dec 17, 2013, at 5:28 PM, Drew Tomlinson <drew at mykitchentable.net> wrote:
> 
> I'm trying to figure out where the system wide bash login script should be for FBSD 9.2.  I've tried /etc/profile, /usr/local/etc/profile, and I even found reference to creating a .bashrc file in home directories, testing for /usr/local/etc/profile, and then calling it if it exists.  None of this seems to work.  However if I paste the contents into a shell after logging in, I get the expected behavior.
> 
> What am I missing?
> 
> Thanks,
> 
> Drew
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list