0

I think /etc/profile is sourced when the system starts but what sources it? It is not sourced within the .bashrc hierarchy when a user logs in. I am using Ubuntu but I believe this is universal across distributions.

muru
  • 72,889
amphibient
  • 12,472
  • 18
  • 64
  • 88

1 Answers1

2

man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists.

So, it's your shell. It gets read before .bashrc. There's certainly also shells that just ignore that file, for example, I think [t]csh doesn't care about it.

  • /etc/profile is used by all Bourne-shell compatible shells - including bash, ash, dash, ksh, and zsh. Some of these have other global profile scripts they use in addition to (or instead of) /etc/profile. They also have per-user profile scripts in ~, which can vary depending on whether the shell is a login shell or not. Or whether they're invoked as /bin/sh or not. It can be complicated. /etc/profile isn't used by csh or tcsh at all (they use /etc/csh.cshrc or /etc/csh.login instead, depending on whether they're login or non-login shells) because they're not bourne-compatible. – cas Jan 08 '22 at 05:58
  • @cas You should make that an answer, not a comment. – Marc Wilson Jan 09 '22 at 00:34